对于整个应用程序,打开项目文件,转到"常规"选项卡,更改设置:

或直接在Info.plist文件中:

如果您只想在特定视图控制器上使用它,请覆盖supportedInterfaceOrientations:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
您可以在官方UIViewController文档中阅读有关第二种方法的更多信息.也许,您会找到更适合您具体问题的方法.
UIViewController *c = [[UIViewController alloc]init];
[self presentViewController:c animated:NO completion:nil];
[self dismissViewControllerAnimated:NO completion:nil];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4382 次 |
| 最近记录: |