风景模式只适用于iPhone或iPad
我想创build一个不使用纵向模式的应用程序。
我不确定是否需要编辑plist或者除了plist还有代码
代码在这里find
在景观模式下启动
iPhone OS中的应用程序通常以纵向模式启动,以匹配主屏幕的方向。 如果您的应用程序在纵向和横向两种模式下都运行,则应用程序应始终以纵向模式启动,然后根据设备的方向让其视图控制器根据需要旋转界面。 但是,如果您的应用程序仅以横向模式运行,则必须执行以下步骤,以使其最初以横向模式启动。
在您的应用程序的Info.plist文件中,添加
UIInterfaceOrientation
键,并设定其值
风景模式。 景观
方向,你可以设置的价值
这个关键到
UIInterfaceOrientationLandscapeLeft
要么
UIInterfaceOrientationLandscapeRight.在横向模式下布置您的视图,并确保他们的autoresizing选项设置正确。
覆盖你的视图控制器的
shouldAutorotateToInterfaceOrientation:方法,并返回YES仅用于
所需的横向和NO
为纵向取向。
 要仅使您的应用横向模式,您应该使用“支持的接口方向”。  ( Targets -> YourApp -> Supported Interface Orientations -> Landscape Left & Right ) 

 您还应该在应用程序的Info.plist文件中设置应用程序的方向 
  )通过将Supported interface orientations键添加到值Landscape (left home button)和Landscape (right home button) 。 
 您可以使用willRotateToInterfaceOrientation和/或didRotateFromInterfaceOrientation来处理方向更改。 
  shouldAutorotateToInterfaceOrientation从iOS 6弃用。 
 对于shouldAutorotateToInterfaceOrientation返回UIDeviceOrientationLandscapeLeft/Right应该让你的应用“风景”: 
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); } 
 也可能会改变你的应用程序的Info.plist和View Orientation (如上所述)。 
 另外,我build议在“ 属性”检查器中将视图的方向更改为“ Landscape ”。 
你也可以缩短这一切
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return UIInterfaceOrientationIsLandscape(interfaceOrientation); } 
 编辑plist只支持横向,然后确保在每个uiviewcontroller / uitabbar等,在shouldAutoRotateToInterfaceOrientation, return说return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));  。