从推送通知打开场景
Open scene from Push notifications
我有这样的故事板:
当你收到推送通知时,我需要打开上图所示的场景。我这样试过:
-(void)application:(UIApplication*)app didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NotificationsViewController *notificationobject = [[NotificationsViewController alloc]init];
[self.navigationController pushViewController:notificationobject animated:YES];
gotNotifcation = YES;
}
但只有它打开NavigationControll 黑色。我该怎么办?
你的故事板中有 NotificationsViewController,但我不确定你正在执行分配和初始化的对象是同一个视图控制器。
尝试这样做:
// replace everything between the quotes with the correct name & identifiers
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"myStoryboardName" bundle:nil];
NotificationsViewController *vc = (NotificationsViewController *)[storyboard instantiateViewControllerWithIdentifier:@"myNotificationsViewController"];
[self.navigationController pushViewController:notificationObject animated:YES];
gotNotification = YES;
或者,因为那里似乎有一个 segue 可以让您进入故事板,请尝试这样做:
[self performSegueWithIdentifier:@"SegueIdentifier" sender:self];
我有这样的故事板:
当你收到推送通知时,我需要打开上图所示的场景。我这样试过:
-(void)application:(UIApplication*)app didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NotificationsViewController *notificationobject = [[NotificationsViewController alloc]init];
[self.navigationController pushViewController:notificationobject animated:YES];
gotNotifcation = YES;
}
但只有它打开NavigationControll 黑色。我该怎么办?
你的故事板中有 NotificationsViewController,但我不确定你正在执行分配和初始化的对象是同一个视图控制器。
尝试这样做:
// replace everything between the quotes with the correct name & identifiers
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"myStoryboardName" bundle:nil];
NotificationsViewController *vc = (NotificationsViewController *)[storyboard instantiateViewControllerWithIdentifier:@"myNotificationsViewController"];
[self.navigationController pushViewController:notificationObject animated:YES];
gotNotification = YES;
或者,因为那里似乎有一个 segue 可以让您进入故事板,请尝试这样做:
[self performSegueWithIdentifier:@"SegueIdentifier" sender:self];