AppDelegate.m
- (void)applicationWillEnterForeground:(UIApplication *)application
{
application.applicationIconBadgeNumber = 0;
}
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
application.applicationIconBadgeNumber = 0;
NSString *reminderText = [notification.userInfo objectForKey:kRemindMeNotificationDataKey];
[self.settings showReminderAlert:reminderText];
NSLog(@"Application REcieved Local Notification");
}
ViewController.m
-(void)showReminderAlert:(NSString *)text{
NSLog(@"Alert Called");
UIAlertView *reminderAlert = [[UIAlertView alloc]initWithTitle:@"Alert" message:text delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[reminderAlert show];
[reminderAlert release];
}
我希望我的应用程序在用户重新登录application.app
didReceiveLocalNotification
时显示警告但是调用了Alert方法。
答案 0 :(得分:1)
您在另一个视图控制器中的showReminderAlert:
对吗?可能是对象self.settings(该视图控制器的对象)在重新打开应用程序时获得释放。在appDelegate本身尝试提醒
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Alarm" message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}