IOS5中的本地通知 - 如何使其在屏幕上而不是在通知中心中弹出?

时间:2011-10-09 12:59:25

标签: iphone objective-c ios5 uilocalnotification

我有一个使用本地通知的应用程序。 现在,当IOS5退出并显示通知警报时 - 它会进入通知中心,现在通过我的2个按钮显示警报(显示和取消)。

有人可以帮我看一下,所以我可以让它弹出屏幕而不是通知中心(屏幕顶部的行)。

这是我的代码:

 UILocalNotification *localNotif = [[UILocalNotification alloc] init];

                localNotif.fireDate=[NSDate date];
                localNotif.timeZone = [NSTimeZone defaultTimeZone];


                localNotif.alertBody = @"Application alerted";

                localNotif.alertAction = @"Show";

                localNotif.soundName = UILocalNotificationDefaultSoundName;
                localNotif.applicationIconBadgeNumber = 0;
                [[UIApplication sharedApplication]presentLocalNotificationNow:localNotif];
                [localNotif release];

谢谢, 阿米尔。

2 个答案:

答案 0 :(得分:6)

只有用户自己才能配置通知警报的显示方式。用户还可以禁用应用程序的通知或禁止通知中心。没有开发人员API。

答案 1 :(得分:2)

你的意思是UIAlertView?您可以使用 - (id)AlertView创建initWithTitle ...您可以配置按钮,如果您的课程是UIAlertViewDelegate,那么您可以听取按钮点击等信息。将弹出屏幕并允许用户将其解除或执行其他操作。