iOS应用的iPad定位-自新发布以来
上次我运行我制作的iOS应用程序时,它一定是为部署目标5.0和相关SDK打开的(可能早在4.3版本就已经打开了)。部署现在是6.1。我的应用程序只运行横向,在横向中运行良好。但在我更新了我的iPad和iOS SDK,并在大约一年内第一次运行这个应用程序之后,似乎有些事情发生了变化 这些按钮的显示方式就像iPad处于纵向模式一样。这是错误的,因为它应该在景观中(过去它工作得很好) 最新更新中发生了什么变化 我在Xcode中支持的界面方向仅选择了“横向右键”,在信息部分,我有“支持的界面方向”,只有一项:“横向(右主按钮)” 在应用程序首次打开时打开的主视图控件中,我有iOS应用的iPad定位-自新发布以来,ios,ipad,Ios,Ipad,上次我运行我制作的iOS应用程序时,它一定是为部署目标5.0和相关SDK打开的(可能早在4.3版本就已经打开了)。部署现在是6.1。我的应用程序只运行横向,在横向中运行良好。但在我更新了我的iPad和iOS SDK,并在大约一年内第一次运行这个应用程序之后,似乎有些事情发生了变化 这些按钮的显示方式就像iPad处于纵向模式一样。这是错误的,因为它应该在景观中(过去它工作得很好) 最新更新中发生了什么变化 我在Xcode中支持的界面方向仅选择了“横向右键”,在信息部分,我有“支持的界面方向”,只有
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
viewDidLoad
的第一行也是
self.view.frame = CGRectMake(0, 0, 1024, 768);
那么,为什么代码绘制按钮好像处于纵向模式
更新
我已尝试将
shouldAutorotateToInterfaceOrientation
方法替换为
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationLandscapeRight & UIInterfaceOrientationLandscapeLeft;
}
但它仍然不起作用。
应该自动旋转指针界面方向在iOS 6中不受欢迎,您应该覆盖它
支持的界面定向
UIViewController的方法
有来自doc的报价:
在iOS 6中,您的应用程序支持在应用程序中定义的界面方向
应用程序的Info.plist文件。视图控制器可以覆盖
supportedInterfaceOrientations方法来限制支持的列表
方向。通常,系统仅在根上调用此方法
要填充的窗口的视图控制器或视图控制器
整个屏幕;子视图控制器使用
由其父视图控制器为其提供的窗口,不再
直接参与关于什么是旋转的决策
支持。应用程序方向遮罩和视图的交点
控制器的方向掩码用于确定哪些方向
视图控制器可以旋转到中
您可以覆盖的preferredInterfaceOrientationForPresentation
一种视图控制器,用于在屏幕上全屏显示
具体方向
iOS6.0中的方向更改 您应该实现以下方法
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
// Set the initial preferred orientation
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
注意如果您使用的是
TabBarController/NavigationController
,则应将这些视图控制器子类化,以覆盖方向方法,使其能够调用您自己的视图控制器方法。这是iOS6中的一个重大变化
#import "UINavigationController+Orientation.h"
@implementation UINavigationController (Orientation)
-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
-(BOOL)shouldAutorotate
{
return YES;
}
@end
那么,现在部署目标是iOS 6.1?
应该在iOS 6中弃用AutoRotateTointerFaceOrientation
。哦……那么我应该怎么做才能解决这个问题呢?您不想在支持的接口方向中使用&
,因为这将返回false。请改用|
。我已将shouldAutorotateToInterfaceOrientation替换为supportedInterfaceOrientations(请参见上面的更新),但问题仍然存在。有什么想法吗?您还需要在应用程序中设置self.window.rootViewController
:使用选项完成启动:
,例如self.window.rootViewController=navigationController代码>。