【发布时间】:2015-08-30 22:23:08
【问题描述】:
我有某些viewControllers 由UINavigationController 管理(推送和弹出)。我想将不同的viewControllers 限制为不同的orientations,比如第一个应该只在Portrait,第二个在portrait,第三个在landscape,第四个可以是portrait 和landscape。我从storyBoard 在isInitialViewController 上设置了ViewController,
- (BOOL) shouldAutorotate{
return NO;
}
工作没有任何问题,但是当我从storyBoard 将navigation controller(通过推送和弹出管理这四个视图)设置为isInitialViewController 时,此函数停止被调用,现在autoratates。如何使用 UINavigationController 作为 isInitialViewController 停止 autorotating 这些视图。我使用以下函数取决于它是哪个ViewController
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return (interfaceOrientation == UIDeviceOrientationPortrait);//choose portrait or landscape}
- (BOOL) shouldAutorotate{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
//return UIInterfaceOrientationMaskLandscape;
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
// return UIInterfaceOrientationLandscapeLeft |
// UIInterfaceOrientationLandscapeRight;
return UIInterfaceOrientationPortrait;
}
【问题讨论】:
标签: objective-c iphone ios8 uinavigationcontroller autorotate