0

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 メソッドが呼び出されていません。

4

1 に答える 1

1

あなたshowReminderAlert:は別のView Controllerにいますか?アプリを再度開くと、オブジェクト 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];
}
于 2013-02-20T07:26:34.123 に答える