2012-04-02 10 views
5

Tengo un UIActionSheet para iPad que tiene tres opciones:UIStatusBarStyleBlackTranslucent no está disponible en este dispositivo

  1. cancelar
  2. cámara
  3. Fototeca

Cuando toco la "biblioteca de fotos "La opción me da un bloqueo y un mensaje

UIStatusBarStyleBlackTranslucent no está disponible en este dispositivo.

He leído this post, pero no lo resolvió.

¿Alguien me puede ayudar?

actualización:

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

consigo accidente en la última línea, es decir [self presentModalViewController:imgController animated:YES];

+1

Lea lo que post? – BoltClock

+0

Lo siento. Perdido. Ahora editado. Por favor, compruebe. – Nitish

Respuesta

0

Prueba a eliminar la configuración de la barra de estado del archivo plist todos juntos y añadiendo lo siguiente a su AppDelegate'sapplicationDidFinishLaunchingWithOptions:

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

ACTUALIZACIÓN:

probar este

-(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

No, no ayudó. Por favor mira mi pregunta editada. – Nitish

+0

Verifique la actualización, esto es lo único que veo de inmediato que lo hubiera hecho de manera diferente. –

+0

¿Cuál es la diferencia? – Nitish

0

Un poco tarde, pero es el UIViewController cuál está llamando presentModalViewController:animated: un niño de un UIPopoverController? Si es así, eso es lo que está causando esto. Trate de llamar desde los panecillos parentViewController

1

tratar a continuación código de sus obras para mí perfecto

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

    } 
10

para el iPad, se recomienda que usted debe utilizar popover para presentar el MediaBrowser (cámara/PhotoLibrary):

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

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

también puede configurar la vista de contenido para 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]; 
0

Así como usted señaló con the post que ha leído, la solución simple sería agregar una fila en el plist con la siguiente clave-valor

UIStatusBarStyle ~ ipad | Cadena | UIStatusBarStyleBlackOpaque

(3rd row in the picture here, sorry cause I can't post image yet now)

Ésta es una de las soluciones, si usted no quiere hacer demasiado "trabajo sucio" en los códigos de ahí, sólo dejar que el plist a hacer el trabajo.

Pero si no te importa escribir códigos, la solución dada por VSN hará lo mismo que mi sugerencia.

Cuestiones relacionadas