iOS屏幕旋转控制
{
return [self.topViewController shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
}
//6.0之后系统调用该方法
- (BOOL)shouldAutorotate
{
//系统会调用跟视图的旋转控制方法,所以我们将跟视图将控制条件交给顶层视图(顶层视图即我们需要控制的视图)
系统调用该方法
return self.topViewController.shouldAutorotate;
}
//6.0之后系统调用该方法,应该支持的方向
-(NSUInteger)supportedInterfaceOrientations
{
return self.topViewController.supportedInterfaceOrientations;
}
三、跟视图为UITabBarController(在UITabBarController中设置)
//6.0之后系统调用该方法
- (BOOL)shouldAutorotate
{
//返回顶层视图的设置(顶层控制器需要覆盖shouldAutorotate方法)
UINavigationController *nav = (UINavigationController *)[self.viewControllersobjectAtIndex:mainTab.selectedIndex];
return nav.topViewController.shouldAutorotate;
}
return NO;
}
//6.0之后系统调用该方法
-(NSUInteger)supportedInterfaceOrientations
{
//返回顶层视图支持的旋转方向
UINavigationController *nav = (UINavigationController *)[self.viewControllersobjectAtIndex:mainTab.selectedIndex];
return nav.topViewController.supportedInterfaceOrientations;
return 0;
}
四、跟视图为MMDrawerController
//6.0一下系统调用该方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
//返回顶层视图的设置
if (self.openSide == 0) {
//centerShow
MainTabBarController *mainTab = (MainTabBarController *)self.centerViewController;
UINavigationController *nav = (UINavigationController *)[mainTab.viewControllersobjectAtIndex:mainTab.selectedIndex];
NSLog(@"nav.topViewController.supportedInterfaceOrientations : %d", nav.topViewController.shouldAutorotate);
return [nav.topViewController shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
}
return NO;
}
//6.0之后系统调用该方法
- (BOOL)shouldAutorotate
{
//返回顶层视图的设置
if (self.openSide == 0) {
//centerShow
MainTabBarController *mainTab = (MainTabBarController *)self.centerViewController;
UINavigationController *nav = (UINavigationController *)[mainTab.viewControllersobjectAtIndex:mainTab.selectedIndex];
NSLog(@"nav.topViewController.supportedInterfaceOrientations : %d", nav.topViewController.shouldAutorotate);
return nav.topViewController.shouldAutorotate;
}
return NO;
}
//6.0之后系统调用该方法
-(NSUInteger)supportedInterfaceOrientations
{
//返回顶层视图支持的旋转方向
if (self.openSide == 0) {
//centerShow
MainTabBarController *mainTab = (MainTabBarController *)self.centerViewController;
UINavigationController *nav = (UINavigationController *)[mainTab.viewControllersobjectAtIndex:mainTab.selectedIndex];
NSLog(@"nav.topViewController.supportedInterfaceOrientations ; %d", nav.topViewController.supportedInterfaceOrientations);
return nav.topViewController.supportedInterfaceOrientations;
} else if (self.openSide == 1) {
//leftShow
}
return 0;
}
五、presentViewController视图控制
模态弹出来的视图,并不能在window的跟视图中控制,(因为它不在这个堆栈中?)如果模态视图为UINavigationcontrollor,则需要交给他自己的UINavigationcontrollor中控制。