1.常规设置屏幕旋转  (Device Orientation || info.plist-----这两个地方的设置是同步的)

 

1)targets->General->Deployment Info->Device Orientation  直接勾选想要的设备定位全局属性

 

 

 

2)Supporting Files->Info.plist->Supported interface orientations 增删属性值

 

 

 

2.个别页面强制横竖屏

新建一个NavigationController类

实现下面三个方法

 

-(BOOL)shouldAutorotate

{//是否支持自动旋转

    return YES;

}

-(NSUInteger)supportedInterfaceOrientations

{//支持的旋转方向

    return [self.viewControllers.lastObject

            supportedInterfaceOrientations];

}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{//进入界面后的默认方向

    return [self.viewControllers.lastObject

            preferredInterfaceOrientationForPresentation];

}

 

 

 

 

如果push出的ViewController需要改变屏幕方向横屏或者竖屏

在当前的ViewController中重写这三个方法,但是如果NavigationController中实现了shouldAutorotate这个方法,则在ViewController中不再执行重写的shouldAutorotate方法。

 

-(BOOL)shouldAutorotate

{//是否支持自动旋转

    return YES;

}

 

-(NSUInteger)supportedInterfaceOrientations

{//支持的旋转方向

    return  (枚举值);

}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{//进入界面后的默认方向

    return  (枚举值);

}

 

posted on 2015-06-17 11:26  韩江河  阅读(2054)  评论(0编辑  收藏  举报