iPhone应用程序只有纵向模式

use*_*133 1 iphone objective-c

如何才能使我的应用始终处于纵向模式.如果我旋转iPhone,它不应该以横向模式显示应用程序.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortrait);

return YES;
}
Run Code Online (Sandbox Code Playgroud)

在此编码后我旋转iPhone应用程序以横向模式显示.如何让应用程序始终处于纵向模式.

Bol*_*ock 9

删除方法 - 您不需要它.iPhone应用程序始终以纵向模式启动,除非您强制它以横向模式启动.如果没有此方法,它将保持纵向模式,因为它实际上意味着"我的视图不会响应界面方向更改".

顺便提一下,这个方法实际上是在Xcode的视图控制器模板中注释掉的,这与它根本就不存在相同.


iWi*_*ard 5

在Xcode点击留下您的项目名称顶部,然后右下方的"目标",你可以设置"支持的设备取向".