标签: cocoa
有没有办法检测应用何时不再有效?也就是说,听听对此的更改:
[NSApp isActive]
答案 0 :(得分:6)
在您的应用代理中,实施您选择的-applicationDidResignActive:或-applicationWillResignActive:。
-applicationDidResignActive:
-applicationWillResignActive:
或者,在NSApp上收听NSApplicationDidResignActiveNotification或NSApplicationWillResignActiveNotification通知。
NSApplicationDidResignActiveNotification
NSApplicationWillResignActiveNotification