- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我知道 UIActionSheet
在 iOS 8 中已被弃用,但我仍然需要 API,因为我仍然以 iOS 7 为目标。
这就是问题所在:我的应用同时支持手机设备的 UIInterfaceOrientationPortrait
和 UIInterfaceOrientationPortraitUpsideDown
。当我的应用程序以正常纵向显示 UIActionSheet
时,一切都很好。但是,如果设备倒置,操作表也会倒置显示,如下所示:
仅当应用程序在装有 iOS 8 的设备(或模拟器)上运行时,问题才存在。当应用程序在装有 iOS 7.1 的模拟器上运行时,问题就消失了(我没有真正的设备iOS 7.1 进行测试)。当我的应用程序仍然使用 iOS 8 之前的 SDK 构建时,问题也从未发生过,即使该应用程序在装有 iOS 8 的设备上运行也是如此。
有没有人建议我在这里可能做错了什么?有关重现该问题的最小示例,请参见下面的代码片段。我正在使用 Xcode 6.1.1 和 iOS SDK 8.1 进行编码。我保证我没有以任何方式摆弄 Xcode 应用程序包:-)
重现问题的步骤
doIt:
的方法最后,在ViewController.m
中添加如下代码:
- (void) doIt:(id)sender
{
UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:@"sheet title"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet addButtonWithTitle:@"sheet action"];
[actionSheet showInView:self.view];
}
// This override is required so that interface orientation
// to UIInterfaceOrientationPortraitUpsideDown is possible
- (NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
运行应用程序,旋转并点击按钮,您应该明白我的意思。
最佳答案
在 ios 8 中,我认为你最好改用 UIAlertController。处理这种奇怪的情况会更好。
关于ios - 为什么UIActionSheet在UIInterfaceOrientationPortraitUpsideDown中是倒着显示的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29201897/
我是一名优秀的程序员,十分优秀!