我的场景:我有一个应用程序,用按钮向发送通知。这个通知是要告诉我什么时候有人敲响我们的船坞门铃。这个按钮应该会拉出一个显示我们码头摄像头的NSWindow。我可以让窗口在应用程序中生成一个NSButton,但我无法让它产生通知按钮。
我试过:
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification {
if ([notification.title isEqualToString:@"Doorbell"]) {
[DockCameraWindow makeKeyAndOrderFront:nil];
NSLog(@"CameraWindow");
}
[[NSUserNotificationCenter defaultUserNotificationCenter] removeAllDeliveredNotifications];
}日志会显示,但是窗口不会显示。然而,我的应用程序会出现前端应用程序的状态。
发布于 2013-10-31 05:17:46
你试过这个吗?--
[NSApp activateIgnoringOtherApps:YES];https://stackoverflow.com/questions/19697001
复制相似问题