【发布时间】:2015-05-05 11:56:49
【问题描述】:
我无法显示我的 UIAlertController,因为我试图在不是 ViewController 的类中显示它。
我已经尝试添加它:
var alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert)
UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertController, animated: true, completion: nil)
哪个不工作... 我还没有找到任何适合我的解决方案。
【问题讨论】:
-
你现在不是 UIViewController 的类部分无法测试。考虑添加一个委托或基于块的回调,以在使用此类的视图控制器上显示警报。
标签: ios swift uialertcontroller