ipad uipopovercontroller landscape ios6

ipad - Las orientaciones admitidas no tienen una orientación común con la aplicación, y shouldAutorotate está devolviendo SÍ.



uipopovercontroller landscape (12)

Crear una categoría es realmente útil para solucionar este error. Y no olvide importar su categoría creada. Esto agregará el método que falta a UIImagePickerController y en iOS 6 restringirá su funcionamiento en Portrait solo cuando la documentación indique por cierto.

Las otras soluciones pueden haber funcionado. Pero con SDK para iOS 8.x compilado para implementar en iOS 6.1, este parece ser el camino a seguir.

El archivo .h:

#import <UIKit/UIKit.h> @interface UIImagePickerController (iOS6FIX) - (BOOL) shouldAutorotate; - (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation; @end

El archivo .m:

#import "UIImagePickerController+iOS6FIX.h" @implementation UIImagePickerController (iOS6FIX) - (BOOL) shouldAutorotate { return NO; } - (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } @end

Mi aplicación (iPad; iOS 6) es una aplicación de solo paisaje, pero cuando intento usar un UIPopoverController para mostrar la biblioteca de fotos arroja este error: las Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES. Intenté cambiar mucho el código, pero no tuve suerte.


Después de pasar mucho tiempo buscando una forma de evitar la subclasificación y agregar toneladas de código, aquí está mi solución de código de una sola línea.

Crea una nueva categoría de UIImagePickerController y agrega

-(BOOL)shouldAutorotate{ return NO; }

¡Eso es todo amigos!


En IOS6, ha admitido orientaciones de interfaz en tres lugares:

  1. El .plist (o pantalla de resumen de objetivos)
  2. Su UIApplicationDelegate
  3. El UIViewController que se muestra

Si recibe este error, es muy probable que la vista que está cargando en su UIPopover solo sea compatible con el modo vertical. Esto puede ser causado por Game Center, iAd o tu propia vista.

Si es su propia vista, puede solucionarla anulando las Orientaciones de interfaz soportadas en su UIViewController:

- (NSUInteger) supportedInterfaceOrientations { //Because your app is only landscape, your view controller for the view in your // popover needs to support only landscape return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; }

Si no es su propia vista (como GameCenter en el iPhone), debe asegurarse de que su .plist sea compatible con el modo vertical. También debe asegurarse de que su UIApplicationDelegate sea compatible con las vistas que se muestran en modo vertical. Puede hacerlo editando su .plist y luego anulando la OrientaciónInterfaz soportada en su UIApplicationDelegate:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; }



Hay otro caso en que este mensaje de error puede aparecer. Estuve buscando durante horas hasta que encontré el problema. Este hilo fue muy útil después de leerlo un par de veces.

Si su controlador de vista principal gira hacia la orientación horizontal e invoca un controlador de subvista personalizado que debe mostrarse en orientación vertical, este mensaje de error puede aparecer cuando su código se ve así:

- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationPortrait; }

La trampa aquí fue intellisense de xcode sugirió "UIInterfaceOrientationPortrait" y no me importó. A primera vista, esto parecía ser correcto.

La máscara derecha se llama

UIInterfaceOrientationMaskPortrait

Tenga en cuenta el pequeño infijo "Máscara" , de lo contrario su subvista terminará con una excepción y el mensaje de error mencionado anteriormente.

Las nuevas enumeraciones están modificadas. ¡Las antiguas enumeraciones devuelven valores inválidos!

(en UIApplication.h puede ver la nueva declaración: UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait) )

La solucion es:

- (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { // ATTENTION! Only return orientation MASK values // return UIInterfaceOrientationPortrait; return UIInterfaceOrientationMaskPortrait; }

En uso rápido

override func shouldAutorotate() -> Bool { return true } override func supportedInterfaceOrientations() -> Int { return Int(UIInterfaceOrientationMask.Portrait.rawValue) }


Me encontré con este problema al convertir implícitamente UIInterfaceOrientationPortrait a UIInterfaceOrientationMaskPortrait como un valor de retorno.

Más información sobre el código en UIPageViewControllerDelegate , solo FYI para todos ustedes.

-(UIInterfaceOrientationMask)pageViewControllerSupportedInterfaceOrientations: (UIPageViewController *)pageViewController { # return UIInterfaceOrientationPortrait; # wrong return UIInterfaceOrientationMaskPortrait; # correct }


Otra opción que resolvió mis problemas fue crear una subclase del UIImagePickerController y anular el siguiente método

@interface MyImagePickerController () @end @implementation MyImagePickerController - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }

Use esto en lugar del UIImagePickerController y todo funciona bien.


Tuve el mismo problema y esta respuesta https://.com/a/12523916 me funciona. Me pregunto si hay una solución más elegante.

Mi código:

UIImagePickerController *imagePickerController = [[NonRotatingUIImagePickerController alloc] init]; imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; UIPopoverController *popoverVC = [[UIPopoverController alloc] initWithContentViewController:imagePickerController]; [popoverVC presentPopoverFromRect:frame // did you forget to call this method? inView:view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


Tuve un problema similar al presentar el selector de imágenes en una aplicación de solo paisaje. Como lo sugirió el Dr. Luiji, agregué la siguiente categoría al comienzo de mi controlador.

// This category (i.e. class extension) is a workaround to get the // Image PickerController to appear in landscape mode. @interface UIImagePickerController(Nonrotating) - (BOOL)shouldAutorotate; @end @implementation UIImagePickerController(Nonrotating) - (BOOL)shouldAutorotate { return NO; } @end

Es más fácil agregar estas líneas justo antes de la @implementación de su archivo ViewController .m.


iOS 8: puedes usar UIModalPresentationPopover sin ningún truco para mostrar en un popover. No es ideal, pero es mejor que nada.

imagePicker.modalPresentationStyle = UIModalPresentationPopover; imagePicker.popoverPresentationController.sourceView = self.view; imagePicker.popoverPresentationController.sourceRect = ((UIButton *)sender).frame;

Editar: tal vez intente con los diferentes UIModalPresentationStyles: quizás funcione más en el paisaje.


Swift 3

let imagePicker = UIImagePickerController() imagePicker.modalPresentationStyle = .popover imagePicker.popoverPresentationController?.sourceView = sender // you can also pass any view present(imagePicker, animated: true)


- (BOOL)shouldAutorotate { return NO; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } This removes the crash.