RootViewController.mm文件里找到 - (NSUInteger) supportedInterfaceOrientations方法。如果想让程序是竖屏,直接return
UIInterfaceOrientationMaskPortrait。横屏是默认的,当然也可以选择别的,自己跟到源码里找,应该不难。
大概是以下几个
UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),
UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),
UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),
UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),
UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight)
其余地方貌似不用改
iOS竖屏锁定教程
本文介绍如何在iOS应用中设置屏幕方向,特别是如何锁定应用为竖屏模式。通过修改RootViewController.mm文件中的-(NSUInteger)supportedInterfaceOrientations方法并返回UIInterfaceOrientationMaskPortrait,可以轻松实现这一目标。
1370

被折叠的 条评论
为什么被折叠?



