方法presentViewController在更新后无法在iOS 8.3上运行

时间:2015-04-14 07:03:02

标签: ios swift

我刚刚将Xcode更新到版本6.3(使用iOS SDK 8.3),而我的项目 - 在8.1和8.2上完美运行 - 似乎在presentViewController方法中存在一些问题。

代码:

var alert = UIAlertController(title: "\(Percent)%", message: TipsMessage, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler:nil))
self.presentViewController(alert, animated: true, completion: nil)

有人可以帮我吗?

1 个答案:

答案 0 :(得分:1)

添加此alertController是超类....

lazy var alertController: UIAlertController = { [weak self] in
        let alert = UIAlertController(title: "Alert", message: "This is a demo alert", preferredStyle: .Alert)

        alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
        return alert
        }()

override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        self.presentViewController(alertController, animated: true, completion: nil)
    }