ローカル通知を受け取ったら、特定の画面を開きたいです。現在私のアプリでは、ナビゲーションコントローラーとモデルビューコントローラーの両方を使用しているため、ナビゲーションコントローラーの時点で、アプリはビューを切り替えていますが、モデルコントローラーの終了時です。画面を開いていません。Plzは解決策を提案しますか?
1 に答える
1
There are two way to launch app when notification comes.
1-アプリはバックグラウンドで実行されています。次に、次のような特定の画面を開きます-(void)application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification {
// write this line
[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadData" object:self];
}
in which controller class you are create notification.
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadTable)
name:@"reloadData"
object:nil];
}
- (void)reloadTable
{
// create object of that controller which your want to open.
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
AddToDoViewController *cvc = (AddToDoViewController *)[sb instantiateViewControllerWithIdentifier:@"AddToDo"];
[self presentModalViewController:cvc animated:YES];
}
于 2013-07-11T12:22:58.910 に答える