Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
579 views
in Technique[技术] by (71.8m points)

iphone - Multiple UIInterfaceOrientations app with iOS 6

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...