Xcode iOS 6模式视图应自动旋转并支持接口方向不工作
我在appDelegate类中编写了这部分代码,以控制应用程序的方向Xcode iOS 6模式视图应自动旋转并支持接口方向不工作,xcode,view,ios6,orientation,modalviewcontroller,Xcode,View,Ios6,Orientation,Modalviewcontroller,我在appDelegate类中编写了这部分代码,以控制应用程序的方向 - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { NSUInteger orientations = UIInterfaceOrientationMaskAll; if (self.window.rootViewControlle
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
NSUInteger orientations = UIInterfaceOrientationMaskAll;
if (self.window.rootViewController) {
UIViewController* presented = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
orientations = [presented supportedInterfaceOrientations];
}
return orientations;
}
我用这个代码来锁定我的方向
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
这适用于NavigationViewController推送的所有ViewController,但不适用于modal提供的ViewController(我的modal视图似乎没有覆盖此代码)
当ViewController由modal显示时,代码示例不起作用。我的ViewController(模式视图)仍处于纵向
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}