我想检测系统alertView何时出现在屏幕上的应用内购买确认提醒。 我正在尝试将键值观察器添加到UIApplication中,但它不起作用。
UIApplication.sharedApplication().addObserver(self, forKeyPath: "windows", options: NSKeyValueObservingOptions.allZeros, context: &myContext)
答案 0 :(得分:3)
这不是我想要的,但它对我有用。
NotificationCenter.addObserver(self, selector: "applicationWillResignActive", name: UIApplicationWillResignActiveNotification, object: nil)
NotificationCenter.addObserver(self, selector: "applicationDidBecomeActive", name: UIApplicationDidBecomeActiveNotification, object: nil)
func applicationDidBecomeActive()
{
if Library.isPurchasing
{
Application.networkActivityIndicatorVisible = true
}
}
func applicationWillResignActive()
{
if Library.isPurchasing
{
Application.networkActivityIndicatorVisible = false
}
}
答案 1 :(得分:0)
查看UIAlertViewDelegate
文档。有willPresentAlertView:
,didPresentAlertView:
,alertView:willDismissWithButtonIndex:
和alertView:didDismissWithButtonIndex:
等方法。