-1

有什么方法可以知道 Mac 是在后台还是前台?

在 iOS 中我们有以下方法: applicationWillEnterForeground applicationWillenterBackground

但是有什么方法可以知道 Mac 是活动的还是非活动的?

4

1 回答 1

1

这取决于您的应用程序布局,但通常使用NSApplication委托并实现:

- (void)applicationWillBecomeActive:(NSNotification *)aNotification

以及它的对应物

- (void)applicationWillResignActive:(NSNotification *)aNotification

还有其他通知。请参阅上面的链接文档。另请注意,OS X 允许真正的多任务处理,因此背景/前景通常指的是有焦点或没有焦点。

于 2014-03-13T13:00:52.630 回答