【发布时间】:2013-07-13 09:07:36
【问题描述】:
我想要的是 iPhone 的纵向和 iPad 应用的横向。
我的应用程序针对 > ios5
我在网上对此进行了搜索,但得到了不同的答案,但不是确切的答案。
【问题讨论】:
我想要的是 iPhone 的纵向和 iPad 应用的横向。
我的应用程序针对 > ios5
我在网上对此进行了搜索,但得到了不同的答案,但不是确切的答案。
【问题讨论】:
这就是我所做的
对于 iPhone
对于 iPad
对于我在下面代码中添加的 iPad 控制器,ios6 应用程序不需要这样做
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
【讨论】:
您只需将此代码添加到您的应用委托中即可做到这一点。
Swift 代码:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> Int {
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
return Int(UIInterfaceOrientationMask.Portrait.rawValue)
} else {
return Int(UIInterfaceOrientationMask.LandscapeLeft.rawValue | UIInterfaceOrientationMask.LandscapeRight.rawValue)
}
}
【讨论】: