iPhone/iPad 应用程序介绍

标签 iphone xcode orientation

我的应用程序的 iPhone 版本支持 UIDeviceOrientationPortraitUpsideDownUIDeviceOrientationPortrait,但 iPad 版本支持所有方向。

在我的 View Controller 中我有这个:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation     {
    return YES;
}

我的 Info.plist 文件有这个:

enter image description here

问题是,当我在 iPod 上构建应用程序时,该应用程序不会颠倒过来。 iPad 将支持所有方向。

我尝试将 shouldAutorotateToInterfaceOrientation 全部删除,并尝试了以下代码:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation = UIDeviceOrientationLandscapeLeft) && (interfaceOrientation = UIDeviceOrientationLandscapeRight) && (interfaceOrientation = UIDeviceOrientationPortraitUpsideDown) && (interfaceOrientation = UIDeviceOrientationPortrait);
}

但由于某种原因,颠倒是行不通的!还有其他解决方案吗?

编辑:使用 Xcode 4.5 iOS6

最佳答案

弄清楚了,iOS6 SDK 使用 shouldAutorotate 所以这是我的新代码:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

-(BOOL)shouldAutorotate {
     return YES;
}

-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

关于iPhone/iPad 应用程序介绍,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12540152/

相关文章:

ios - MFMailComposeViewController 的 UINavigationBar 不一致地显示正确的图像/颜色

android - 如何将图像旋转到从 Android 中的图库中选择的默认方向?

iphone - UIDevice currentDevice 的 "orientation"始终为 null

ios - 解释 iOS7 中自动调整 ScrollView 插入、扩展布局包含不透明条、边缘ForExtendedLayout 之间的区别

xcode - 如何在 Xcode 自动补全中从一个占位符跳转到下一个占位符?

ios - 如何在 iOS 中将相机 View 方向锁定为横向?

iphone - iOS自动引用计数(ARC)向后兼容性?

iphone - UIImageWriteToSavedPhotosAlbum 未在左下角显示缩略图

iphone - 从 NSString 写入 NSMutableArray

ios - 添加一个按钮以 float 在 ViewController 之上,受 Path 启发