当两个alert 一个接一个出现时,我指的是一个alert 出现,另一个alert 出现,应用程序崩溃.

请在这一点上帮助我.

推荐答案

This is a bug in iOS 9 that it failed to retrieve the supportedInterfaceOrientations for UIAlertController. And it seems it dropped to an infinite recursion loop in looking for the supportedInterfaceOrientations for UIAlertController (e.g., it tracks back to UIAlertControler -> UIViewController -> UINavigationController -> UITabBarController -> UIAlertController -> ...), while the call to UIAlertController:supportedInterfaceOrientations actually is not implemented/overridden in the source code.

在我的解决方案中,我刚刚添加了以下代码:

extension UIAlertController {     
    public override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.Portrait
    }
    public override func shouldAutorotate() -> Bool {
        return false
    }
}

然后UIAlertController将直接返回支持的方向值,无需无限循环.希望有帮助.

Edit: Swift 3.0.1

extension UIAlertController {
    open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.portrait
    }  
    open override var shouldAutorotate: Bool {
        return false
    }
}

Objective-c相关问答推荐

react 本机WebView菜单项目props 无法在iOS&>=16上使用

当 UITextField 成为第一响应者时如何使 UIScrollView 自动滚动

UIButton 标题更改为默认值

animateWithDuration:animations: 会阻塞主线程吗?

Objective-C 中的正式协议和非正式协议有什么区别?

如果用户点击屏幕键盘,我如何关闭键盘?

与 iOS 6.0 原生 Facebook 集成共享:通过我的应用名称发布?

在基于视图的 NSTableView 上更改 Select colored颜色

我可以以编程方式滚动到 UIPickerView 中所需的行吗?

我如何使用 initWithCoder 方法?

以编程方式创建 UITableView

在Objective-C中替换字符串中的多个字符?

iOS 设备作为 Web 服务器

每个 ivar 都必须是一个属性吗?

NSMutableArray addObject 不起作用

获取最顶层的 UIViewController

围绕其中心旋转 UIView 保持其大小

iOS 上的电话号码格式

Unwind Segue 在 iOS 8 中不起作用

使用 [NSDate date] 获取当前日期和时间