Multiple UIInterfaceOrientations app with iOS 6

坚强是说给别人听的谎言 提交于 2020-01-10 03:13:26

问题


I'm having a bad time trying to set the new UIInterfaceOrientations from iOS 6.

Resuming my app:

  • My app have a bunch of views;
  • Almost every view should be shown on Portrait orientation;
  • 2 of my views (the ones that play videos with MPMoviePlayerViewController) should rotate to left, right and portrait orientations.

My original idea was to set the app supported orientation to Portrait and than change (don't know how) the supported orientation from the video player views.

What would be the best way to deal with this?

Thank you in advance!


回答1:


The problem was solved using by setting the Supported Interface Orientations to all I need (Portrait, Landscape right and left) and adding one Category of UINavigationController.

I added the Category to any occurrence of UINavigationController that I want to stay on Portrait mode and treated the iOS 6 rotation like this post:

@implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

@end

With this implemented I still have some problems because the code was like this:

[self.window.rootViewController presentModalViewController:controller animated:NO]; 

instead of this:

[self.navigationController pushViewController:controller animated:NO];

With the above changes I was able to keep the entire app on Portrait Mode and let the video player views to keep rotating because their methods (shouldRotate and supportedInterfaceOrientations) weren't overridden.




回答2:


Check out my post: https://stackoverflow.com/a/12538622/1575017 It's the same thing but flipped orientations for you.



来源:https://stackoverflow.com/questions/12610132/multiple-uiinterfaceorientations-app-with-ios-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!