2011-08-28 11 views
9

Estoy utilizando la siguiente función para activar la cámara del dispositivo o el selector de imágenes dependiendo del resultado de una UIActionSheet. si fromCamera = YES entonces funciona tanto en iPhone como en iPad. si fromCamera = NO, funciona en iPhone y aparece el selector de imágenes. Pero se bloquea en el iPad con el siguiente error: UIStatusBarStyleBlackTranslucent no está disponible en este dispositivo. Ya sé que el iPad no puede mostrar la barra de estado UIStatusBarStyleBlackTranslucent, pero ¿cómo puedo evitar este bloqueo?Crash iPad Photo Picker

-(void)addPhotoFromCamera:(BOOL)fromCamera{ 

if(fromCamera){  
    picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
} 
else{ 
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
} 


[self presentModalViewController:picker animated:YES]; 

}

+0

Seguramente alguien ha usado UIImagePickerControllerSourceTypePhotoLibrary con iPad? – wasabi

Respuesta

3

Sospecho que la UIImagePicker está heredando la barra de estado translúcido de su archivo Info.plist o desde el controlador de vista que se muestra actualmente.

¿Qué ocurre si la aplicación no tiene una barra de estado translúcida?

4

Si ajusta el selector para UIImagePickerControllerSourceTypePhotoLibrary en el IPAD, a continuación, debe presentarlo de una popoverview (!) De lo contrario, obtienes excepciones. Lo hago así, a al menos controlar el tamaño de la popover (el tamaño estándar es demasiado pequeña en mi opinión):

-(void)openPhotoPicker 
{ 
    imagePicker = [[UIImagePickerController alloc] init]; 
    imagePicker.delegate = self; 
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
    imagePicker.navigationBar.opaque = true; 

    //put the image picker in its own container controller, to control its size 
    UIViewController *containerController = [[UIViewController alloc] init]; 
    containerController.contentSizeForViewInPopover = rightPane.frame.size; 
    [containerController.view addSubview:imagePicker.view]; 

    //then, put the container controller in the popover 
    popover = [[UIPopoverController alloc] initWithContentViewController:containerController]; 

    //Actually, I would like to do the following, but iOS doesn't let me: 
    //[rightPane addSubview:imagePicker.view]; 

    //So, put the popover over my rightPane. You might want to change the parameters to suit your needs. 
    [popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 10.0,0.0) 
        inView:rightPane 
    permittedArrowDirections:UIPopoverArrowDirectionLeft 
        animated:YES]; 

    //There seems to be some nasty bug because of the added layer (the container controller), so you need to call this now and each time the view rotates (see below) 
    [imagePicker.view setFrame:containerController.view.frame]; 
} 

que también tienen la siguiente, para contrarrestar un error de rotación:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
    if(imagePicker!=nil && rightPane.frame.size.width>0) 
     [imagePicker.view setFrame:imagePicker.view.superview.frame]; 
} 

No es perfecto, pero está bien para mis propósitos de prueba en este momento. Considero escribir mi propio Imagepicker, porque no me gusta que me obliguen a usar Popoverview ... pero bueno, esa es una historia diferente.