我想创建一个不使用肖像模式的应用程序。
我不确定是否需要编辑plist,或者除了plist之外还需要代码。
发布于 2010-04-16 02:02:29
在横向模式下启动
iPhone OS中的应用程序通常以纵向模式启动,以匹配主屏幕的方向。如果你有一个同时在纵向和横向模式下运行的应用程序,你的应用程序最初应该总是在纵向模式下启动,然后让它的视图控制器根据设备的方向根据需要旋转界面。但是,如果您的应用程序仅在横向模式下运行,则必须执行以下步骤才能使其最初以横向方式启动。
UIInterfaceOrientation键,并将其值设置为
横向模式。对于景观
方向,您可以设置该值
此密钥的
UIInterfaceOrientationLandscapeLeft
或
在横向模式下对视图进行UIInterfaceOrientationLandscapeRight.
shouldAutorotateToInterfaceOrientation:方法,并仅为所需的横向方向和无
对于纵向orientations.
发布于 2012-07-19 03:32:50
要使你的应用程序的横向模式仅支持界面,你应该使用“”。(Targets -> YourApp -> Supported Interface Orientations -> Landscape Left & Right)

还应在应用程序的Info.plist文件中设置应用程序的方向(

)通过将值Landscape (left home button)和Landscape (right home button)附加到Supported interface orientations密钥。

您可以使用willRotateToInterfaceOrientation和/或didRotateFromInterfaceOrientation来处理方向更改。
在iOS 6和更高版本中,shouldAutorotateToInterfaceOrientation已弃用。
为shouldAutorotateToInterfaceOrientation返回UIDeviceOrientationLandscapeLeft/Right应该会让你的应用变得“风景”:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}也可能改变你的应用的Info.plist和View Orientation (如上所述)。
此外,我建议在属性检查器中将视图的方向更改为Landscape。

发布于 2011-07-21 21:27:44
您也可以将所有内容缩短为
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}https://stackoverflow.com/questions/2647786
复制相似问题