iOS检测系统弹窗

658 阅读1分钟

When a system alert POP UP, then the function will be called [AppDelegate applicationWillResignActive:], after dismiss the alert then [AppDelegate applicationDidBecomeActive:] will be called. So, it can be detected by add a observer for notifications named UIApplicationDidBecomeActiveNotification and UIApplicationWillResignActiveNotification, such as

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(observeUIApplicationDidBecomeActiveNotification) name:UIApplicationDidBecomeActiveNotification object:nil]; 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(observeUIApplicationWillResignActiveNotification) name:UIApplicationWillResignActiveNotification object:nil];