- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不确定我是否弄错了,但从我能找到的例子来看。我写了那个小小的 helloworld。
#import <Foundation/Foundation.h>
#import <Foundation/NSUserNotification.h>
int main (int argc, const char * argv[])
{
NSUserNotification *userNotification = [[NSUserNotification alloc] init];
userNotification.title = @"Some title";
userNotification.informativeText = @"Some text";
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
return 0;
}
我编译它:
cc -framework Foundation -o app main.m
它可以编译,我可以执行它,但它不会显示任何内容。由于某些原因,什么也没有呈现。我读到如果应用程序是主要参与者,通知可能不会显示。如何让它显示通知?
最佳答案
设置委托(delegate)并覆盖
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
shouldPresentNotification:(NSUserNotification *)notification {
return YES;
}
关于NSUserNotificationCenter 不显示通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15896348/
我不确定我是否弄错了,但从我能找到的例子来看。我写了那个小小的 helloworld。 #import #import int main (int argc, const char * argv[
我正在尝试为我的应用程序使用新的 Mountain Lion NSUserNotificationCenter(实际上并不太难)。通过 发布通知就像魅力一样 NSUserNotification *u
我有一个简单的测试Qt应用程序,尝试在OS X上发送用户通知: void Mac::notify(QString title, QString message) { NSUserNotificat
我正在尝试创建一个会弹出通知的应用程序。我在我的应用程序中使用 NSUserNotificationCenterDelegate,如下所示: class AppDelegate: NSObject,
我正在 mac osx 10.8.5 上用 python 2.7 制作一个应用我想显示通知次数,因此使用 NSUserNotificationCenter。在 Eclipse 上运行代码时会收到通知。
我正在开发一个 swift os x 应用程序,但我无法理解 userNoticiation/didActivateNotification 结构。我已经查看了文档并进行了搜索,但仍然卡住了。非常感谢
当任何 应用程序交付或激活 NSUserNotification 时,如何通知我? 我也无法确定通过 NSDistributedNotificationCenter 发送的任何内容, 我也找不到像 N
我有这样的代码。 [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]
我目前正在尝试使用旧的 NSUserNotification 设置通知服务macOSX(非 iOS)上的 API,采用 Objective C++。问题是我需要知道与用户设置的通知相关的系统首选项(最
我正在尝试通过 node 和 NodObjC 向通知中心发送通知,并且问题是: $.NSUserNotificationCenter('defaultUserNotificationCente
我觉得我快要疯了。 我正在制作一个命令行小工具,让我知道我喜欢的 Twitch channel 何时上线。到目前为止,一切正常。只有一个小问题:[NSUserNotificationCenter de
在 Mountain Lion 的通知中心 (NSUserNotificationCenter) 中是否有任何非隐私的方式知道有多少通知?不仅仅是来 self 的应用程序的通知,而是来自所有应用程序的
我正在尝试将通知发送到通知中心 (Mac OSX)我正在使用 PyObjC 绑定(bind)来使用我们 python 应用程序中的 cocoa api。 我正在使用以下代码片段: import Fou
我正在尝试通过 python 连接到 Mountain Lion 通知中心。我已经安装了 pyobjc 并按照说明进行操作 here和 here .另见:Working with Mountain L
在我们的应用程序中,我们以警报样式显示通知中心通知。 显示通知工作正常,当用户通过单击通知或单击操作按钮与通知交互时我们会收到回调。 但是,我们有兴趣在用户单击通知中的其他按钮时获得回调或事件。我已经
我做了很多研究,但找不到我要找的东西:目前,Deployment Target和Base SDK我的应用程序的设置为 10.8 ,并且运行完美。我可以正确地将通知发布到 Mountain Lions
我是一名优秀的程序员,十分优秀!