【发布时间】:2015-07-01 09:25:37
【问题描述】:
我正在尝试从视图控制器中的一个类调用函数:
var rate = RateMyApp.sharedInstance
rate.showRatingAlert()
在 RateMyApp 类中我调用警报视图:
var window: AnyObject = UIApplication.sharedApplication().keyWindow!;
var vc = window.rootViewController;
vc?!.presentViewController(alert, animated: true, completion: nil)
但是,警报没有显示出来,有一种警告:
Warning: Attempt to present <UIAlertController: 0x15fe3dcf0> on <drawtext.ViewController: 0x16002a800> whose view is not in the window hierarchy!
这种情况时有发生,如果一个人隐藏了应用程序然后再次打开它几次,有时会显示警报。
什么会导致这种奇怪的行为?
【问题讨论】:
-
不,不是,在您的情况下,问题与调用 viewdidappear/viewdidload 有关
标签: ios xcode uialertview hierarchy