
怎么强制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;}

2021-01-25 广告
提供户外强光下可视、高清高亮、超宽视角、工业级宽温中小尺寸TFT液晶屏,可差异化定制,接口可兼容SPI/MCU/RGB/MIPI。以上内容如果还觉得不够全面,也可以沟通下深圳市鸿佳联合科技有限公司。深圳市鸿佳联合科技有限公司专注于中小尺寸T...
点击进入详情页
本回答由深圳市鸿佳联合科技有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询