2013-02-20 53 views
0

AppDelegate.m警報在UILocalNotification是沒有得到所謂的

- (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.appdidReceiveLocalNotification顯示警報獲取調用,但警報方法沒有被調用。

+0

什麼是在 - (void)showReminderAlert:(NSString *)文本中的文字?它根本沒用過 – 2013-02-20 07:21:58

+0

- (void)showReminderAlert:(NSString *)text中有什麼用法?它根本沒有使用 – 2013-02-20 07:23:08

回答

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]; 
} 
+0

要顯示在警報中的文本是在另一個視圖控制器的文本字段中。我已經在另一個運行良好的應用程序中使用了此示例。我不明白我在此應用程序中出錯的位置。 – 2013-02-20 07:33:22

+0

檢查'self.setting'是否爲零?你正在從'notification.userInfo'提取提醒文字?那麼你可以在'didReceiveLocalNotification:'右邊顯示警報? – 2013-02-20 08:11:48

相關問題