UIStatusBarStyleBlackTranslucent在此设备上不可用

Nit*_*ish 5 cocoa-touch ipad ios uistatusbar ios5

我有一个UIActionSheetiPad有三个选项:

  1. 取消
  2. 相机
  3. 图片库

当我触摸"照片库"选项时,我收到了崩溃和消息

UIStatusBarStyleBlackTranslucent在此设备上不可用.

我读了这篇文章,但没弄明白.

有人能帮我吗?

更新:

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 0) 
    {

        imgController = [[UIImagePickerController alloc] init];
        imgController.allowsEditing = YES;
        imgController.sourceType =  UIImagePickerControllerSourceTypeCamera;   
        imgController.delegate=self;
        [self presentModalViewController:imgController animated:YES];

    } 
    else if (buttonIndex == 1) 
    {
        imgController = [[UIImagePickerController alloc] init];
        imgController.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;
        imgController.delegate=self;
        [self presentModalViewController:imgController animated:YES];  
}
}  
Run Code Online (Sandbox Code Playgroud)

我在最后一行崩溃了 [self presentModalViewController:imgController animated:YES];

Zub*_*air 10

对于iPad,建议您使用popover来呈现MediaBrowser(camera/photoLibrary):

UIImagePickerController *ipc = [[UIImagePickerController alloc] init];

UIPopoverController *popOverController = [[UIPopoverController alloc] initWithContentViewController:ipc];
popOverController.delegate = self;
Run Code Online (Sandbox Code Playgroud)

您还可以为popover设置内容视图:

ipc.delegate = self; 
ipc.editing = NO;       
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
ipc.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:ipc.sourceType];

[popOverController presentPopoverFromRect:btnGallery.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Run Code Online (Sandbox Code Playgroud)


Mic*_*lum 0

plist尝试从文件中一起删除状态栏设置并将以下内容添加到您的AppDelegate's applicationDidFinishLaunchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
 [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent];
}
Run Code Online (Sandbox Code Playgroud)

更新:

尝试这个

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (buttonIndex)
{
    case 0: 
    {

        imgController = [[UIImagePickerController alloc] init];
        imgController.allowsEditing = YES;
        imgController.sourceType =  UIImagePickerControllerSourceTypeCamera;   
        imgController.delegate=self;
        [self presentModalViewController:imgController animated:YES];

    } 
    case 1:
    {
        imgController = [[UIImagePickerController alloc] init];
        imgController.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;
        imgController.delegate=self;
        [self presentModalViewController:imgController animated:YES];  
    }
}
} 
Run Code Online (Sandbox Code Playgroud)