UIStatusBarStyleBlackTranslucent is not available on this device

I have an UIActionSheetiPad that has three options:

  • Cancel
  • Camera
  • Photo library

When I touch the "Photo Library" option, I get an error message and a message

UIStatusBarStyleBlackTranslucent is not available on this device.

I read this post but did not understand this.

Can someone help me?

Update :

-(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];  
}
}  

I hit the last line ie [self presentModalViewController:imgController animated:YES];

+5
source share
5 answers

For iPad, it is recommended to use popover to represent MediaBrowser (camera / photoLibrary):

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

UIPopoverController *popOverController = [[UIPopoverController alloc] initWithContentViewController:ipc];
popOverController.delegate = self;

You can also set the content view for 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];
+10
source

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:   (NSInteger)buttonIndex
{
if(buttonIndex==0)
    {
    [self takePhoto];

    }
else if(buttonIndex==1)
    {
    [self choosePhoto];
    }
}


-(void)takePhoto
{
UIDevice *device = [UIDevice currentDevice];

NSString *currDevice = [device model];

NSLog(@"device is %@",currDevice);

   if(![currDevice isEqualToString:@"iPhone Simulator"])
        {
       [[UIApplication sharedApplication]    setStatusBarOrientation:UIInterfaceOrientationPortrait];
    UIImagePickerController *imgPickerCon = [[UIImagePickerController alloc] init];
    imgPickerCon.sourceType = UIImagePickerControllerSourceTypeCamera;
    imgPickerCon.delegate = self;
    [self presentModalViewController:imgPickerCon animated:YES];
    [imgPickerCon release];
    imgPickerCon = nil;
    }
  else{
    UIAlertView *alrt=[[UIAlertView alloc] initWithTitle:@"Message" message:@"Camera Will Not Open in Simulator" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alrt show];
    [alrt release];
}
 }

 -(void)choosePhoto
 {

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
UIImagePickerController *imgPickerCon = [[UIImagePickerController alloc] init];     
imgPickerCon.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imgPickerCon.delegate = self;
[self presentModalViewController:imgPickerCon animated:YES];        
[imgPickerCon release];
imgPickerCon = nil;
  }


  - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[picker dismissModalViewControllerAnimated:YES];
 }

   - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)myimage editingInfo:(NSDictionary *)editingInfo 
  {


[picker dismissModalViewControllerAnimated:YES];
image=myimage;

imgView.image=myimage;

  }
+1

plist AppDelegate's applicationDidFinishLaunchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
 [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent];
}

UPDATE:

-(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];  
    }
}
} 
0

, UIViewController, presentModalViewController:animated: UIPopoverController? , . popovers parentViewController

0

, , plist

UIStatusBarStyle ~ ipad | | UIStatusBarStyleBlackOpaque

( , , )

, " " , plist, .

, , VSN, , .

0

All Articles