Modal View Controller force Landscape orientation in iOS 6

断了今生、忘了曾经 提交于 2019-12-03 12:48:00
Esmond

iOS 6.0 Release Notes
"More responsibility is moving to the app and the app delegate. Now, iOS containers (such as UINavigationController) do not consult their children to determine whether they should autorotate. "

-(BOOL)shouldAutorotate of UIViewController under any Container (like UINavigationController) will not be called from IOS6.

Tried a solution with using Category to add method to existing UINavigationController Class.

inside the shouldAutorotate method, you can call shouldAutorotate method in each view controller of self.viewControllers. In fact, you can pass to your child view controller.

If you want to force rotation in iOS6, your rootviewController should implement these methods:

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotate {
    return YES;
}
CoderDan

In iOS 6 it seems to be this method may help force a specific orientation on iOS 6.

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

I am still trying to get it to work and will update with any findings.

I do exactly this in my app, and do it via shouldAutoRotateToInterfaceOrientation, slightly differently than you:

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
 if (UIInterfaceOrientationIsLandscape(interfaceOrientation))
  return (YES);
 return (NO);
}

for iOS 6, you must also set window.rootViewController = {your root view controller}; in your app delegate. I'm hoping this is your issue

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