接收的本地通知下面的代碼是顯示一個視圖控制器我的最新嘗試時我的應用程序接收到特定本地通知:問題顯示視圖控制器當在iPhone上
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
NSLog(@"Notification Received. UserInfo: %@", [notification.userInfo valueForKey:@"notificationType"]);
if ([[notification.userInfo valueForKey:@"notificationType"] isEqualToString:@"backup"])
{
NSLog(@"Backup notification received.");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"Yes" forKey:@"shouldBackup"];
[defaults synchronize];
SettingsViewController *vc = [self.window.rootViewController.tabBarController.viewControllers objectAtIndex:3];
[self.window.rootViewController.tabBarController.navigationController pushViewController:vc animated:NO];
}
else
{
NSLog(@"Did receive notification: %@, set for date:%@ .", notification.alertBody, notification.fireDate);
}
}
我然後有這一段代碼,我在viewDidAppear方法用來確定羯羊或不執行備份:
if ([[defaults objectForKey:@"shouldBackup"] isEqualToString:@"Yes"]){
[defaults setObject:@"No" forKey:@"shouldBackup"];
[defaults synchronize];
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Backing Up Your Data..";
HUD.minSize = CGSizeMake(135.f, 135.f);
[HUD showWhileExecuting:@selector(performBackup) onTarget:self withObject:nil animated:YES];
}
然而,似乎viewDidAppear是從來沒有所謂的,任何人都可以解釋它是什麼,我做錯了什麼?我現在已經嘗試了幾種不同的方法,我只是似乎無法得到它的工作..
感謝,
Tysin