У меня есть приложение, в котором я использую локальное уведомление, если пользователь какое-то время не открывал приложение.
Если пользователь открывает приложение через локальное уведомление, моя БД обновляется и дает кредиты учетной записи пользователя, и я показываю предупреждение «У вас есть дополнительные кредиты».
Кредиты обновляются в моей БД. Когда пользователь нажимает «ОК», но мой контроллер просмотра не обновляется, и в это время он не показывает обновленные кредиты на метке.
Когда я перехожу к другому виду и возвращаюсь, он показывает.
Как я должен получать обновленные оценки в то время, когда пользователь нажимает «ОК» в AlertView?
Заранее спасибо....
Изменить
[[UIApplication sharedApplication]cancelAllLocalNotifications];
NSDate *today=[NSDate date];
NSLog(@"%@",today);
NSDateFormatter *dateFormat1 = [[NSDateFormatter alloc] init];
[dateFormat1 setDateFormat:@"dd-MMM-yyyy hh:mm:ss a"];
NSTimeInterval secondsInEightHours = 20;
NSString *tt=[dateFormat1 stringFromDate:today];
//tt=@"20-Apr-2013 06:39:32 PM";
NSDate *Ass_date=[dateFormat1 dateFromString:tt];
Ass_date=[Ass_date dateByAddingTimeInterval:secondsInEightHours];
NSLog(@"%@",tt);
NSLog(@"%@",today);
NSLog(@"%@",Ass_date);
//[[UIApplication sharedApplication]cancelAllLocalNotifications];
UILocalNotification *localNotif1 = [[UILocalNotification alloc] init];
[[UIApplication sharedApplication]cancelLocalNotification:localNotif1];
if (localNotif1 == nil)
return;
localNotif1.fireDate = Ass_date;
localNotif1.timeZone = [NSTimeZone defaultTimeZone];
// Notification details
localNotif1.alertBody = @"You have not played for a long time. Play and get 250 Stars credits for free!";
// Set the action button
localNotif1.alertAction = @"Get It Now";
localNotif1.soundName = UILocalNotificationDefaultSoundName;
//localNotif.applicationIconBadgeNumber = 1;
//localNotif1.applicationIconBadgeNumber ++;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif1];
[localNotif1 release];
Это код, который я сделал в ViewDidAppear моего контроллера просмотра.
Теперь в делегате приложения в application didReceiveLocalNotification: я показал предупреждение.
[self localNotif];
////NSLog(@"Recieved Notification %@",localNotif);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"250 Stars have been credited to your account" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
При нажатии кнопки «ОК» из предупреждения я хочу, чтобы мой контроллер представления обновлялся или перезагружался.