【发布时间】:2011-06-25 20:40:19
【问题描述】:
UILocalNotification 遇到了一些非常恼人的问题。
在完成一个我几乎完成的应用程序时,我注意到我无法让本地通知工作,无论我尝试什么。
因此,与其浪费时间,我决定回归基础,看看能否让它们发挥作用。
我创建了一个新的基于 XCode 视图的应用程序,并将 -viewDidLoad 替换为:
- (void)viewDidLoad
{
UILocalNotification * theNotification = [[UILocalNotification alloc] init];
theNotification.alertBody = @"Alert text";
theNotification.alertAction = @"Ok";
theNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
[[UIApplication sharedApplication] scheduleLocalNotification:theNotification];
}
但是,这也没有任何作用。
我希望在启动应用程序 10 秒后看到通知,但没有出现。
另外,我在我的 iPhone 和模拟器上都对此进行了测试。
我在这里错过了一些非常重要的东西吗? (我已经搜索了 Apple 文档,但找不到任何关于为什么会发生这种情况的信息)
谢谢
【问题讨论】:
标签: ios objective-c xcode uilocalnotification