Mi aplicación tiene una instancia de un UIN personalizada La subclase avigationController, que presenta varios controladores de vista, todo en modo retrato solamente, excepto cuando se reproduce un video, en cuyo caso quiero permitir adicionalmente ambas orientaciones de paisaje.
Basado en la respuesta de @uerceg, este es mi código.
Primero, habilité Portrait, Landscape Left y Landscape en Xcode -> Target -> Summary.
En la implementación de la subclase UINavigationController, I #import
'ed <MediaPlayer/MediaPlayer.h>
.
Entonces implementado estos métodos:
// Autorotation (iOS <= 5.x)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([self modalViewController] && [[self modalViewController] isKindOfClass:[MPMoviePlayerController class]]) {
// Playing Video: Anything but 'Portrait (Upside down)' is OK
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
else{
// NOT Playing Video: Only 'Portrait' is OK
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
}
// Autorotation (iOS >= 6.0)
- (BOOL) shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
NSUInteger orientations = UIInterfaceOrientationMaskPortrait;
if ([self modalViewController] && [[self modalViewController] isKindOfClass:[MPMoviePlayerController class]]) {
// Playing Video, additionally allow both landscape orientations:
orientations |= UIInterfaceOrientationMaskLandscapeLeft;
orientations |= UIInterfaceOrientationMaskLandscapeRight;
}
return orientations;
}
Puede ver una solución para admitir la rotación de iOS 6 y iOS 5 aquí: http://stackoverflow.com/questions/12396545/how-to-deal-with-iphone-5-screen-size/12397738#12397738 –
Ver mi solución aquí: http: //stackoverflow.com/questions/12662240/how-to-make-app-fully-working-correctly-for-autorotation-in-ios-6/12662433#12662433 – Carina
Gracias por preguntar esto! He estado tratando de resolver esto por un tiempo, porque las cosas no han funcionado como deberían. – Justin