如何锁定iOS中的屏幕,使其只有纵向方向?

Ash*_*Var 4 rotation orientation ios

我创建了一个包含许多视图的应用程序,我希望其中一些仅以纵向方式显示.我在.m文件中编写了这个代码:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return NO;
}
Run Code Online (Sandbox Code Playgroud)

我还需要做点什么吗?可能在.h文件中?

da *_*res 5

对我来说最干净的解决方案:

转到Info.plist文件,对于"支持的界面方向",删除除"纵向(底部主页按钮)"之外的所有值.