怎么强制UIViewController从竖屏进入横屏
1个回答
展开全部
没地方放压缩包,我就在这里写个简单吧,2个UIViewController,你自己新建一个工程就加两按钮就可以测试。
核心需要添加的方法如下:
1,PortraitViewController 不旋转,保持竖屏//iOS 5- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{return (toInterfaceOrientation == UIInterfaceOrientationPortrait);}//iOS 6- (BOOL)shouldAutorotate{return NO;}- (NSUInteger)supportedInterfaceOrientations{return UIInterfaceOrientationMaskPortrait;}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{return UIInterfaceOrientationPortrait;}LandscapeViewController 始终保持横屏//iOS 5- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{return (toInterfaceOrientation == self.preferredInterfaceOrientationForPresentation);}//iOS 6- (BOOL) shouldAutorotate{return YES;}- (NSUInteger)supportedInterfaceOrientations{return UIInterfaceOrientationMaskLandscapeRight;}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{return UIInterfaceOrient罚互窜就诃脚撮协郸茅ationLandscapeRight;}
核心需要添加的方法如下:
1,PortraitViewController 不旋转,保持竖屏//iOS 5- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{return (toInterfaceOrientation == UIInterfaceOrientationPortrait);}//iOS 6- (BOOL)shouldAutorotate{return NO;}- (NSUInteger)supportedInterfaceOrientations{return UIInterfaceOrientationMaskPortrait;}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{return UIInterfaceOrientationPortrait;}LandscapeViewController 始终保持横屏//iOS 5- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{return (toInterfaceOrientation == self.preferredInterfaceOrientationForPresentation);}//iOS 6- (BOOL) shouldAutorotate{return YES;}- (NSUInteger)supportedInterfaceOrientations{return UIInterfaceOrientationMaskLandscapeRight;}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{return UIInterfaceOrient罚互窜就诃脚撮协郸茅ationLandscapeRight;}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询