ios单个ViewController屏幕旋转-创新互联
如果需要旋转的ViewController 使用了UINavigationController,对UINavigationController进行如下扩展![ios单个ViewControl
ler屏幕旋转 ios单个ViewControl
ler屏幕旋转](/upload/otherpic24/2133522.jpg)
网站名称:ios单个ViewController屏幕旋转-创新互联
分享链接:http://tyjierui.cn/article/dhdcoc.html
![ios单个ViewControl
ler屏幕旋转 ios单个ViewControl
ler屏幕旋转](/upload/otherpic24/2133522.jpg)
@implementation UINavigationController(shouldAutorotate)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return self.topViewController.shouldAutorotate;
}
- (NSUInteger)supportedInterfaceOrientations
{
return self.topViewController.supportedInterfaceOrientations;
}
@end
需要旋转的ViewController设置
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
其他不需要旋转的 ViewController设置,建议添加BaseViewController统一控制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait;
}
网站名称:ios单个ViewController屏幕旋转-创新互联
分享链接:http://tyjierui.cn/article/dhdcoc.html