单击远程通知后能够重定向到指定视图控制器但只有 VC 但没有导航栏
able redirect to specify view controller after clicked remote notification but only VC but without navigation bar
我在用户点击推送通知后设置了一个重定向,它确实有效。然而,该应用程序被重定向到没有导航栏和底部工具栏的视图控制器。下面是我的重定向代码:-
// Did receive notification method here...
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo NS_AVAILABLE_IOS(3_0)
{
NSLog(@"user info1 is %@",userInfo);
[[NSNotificationCenter defaultCenter] postNotificationName:@"NOTIFICATION_RECIEVED"
object:nil
userInfo:nil];
UIStoryboard *mainsboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [mainsboard instantiateViewControllerWithIdentifier:@"notice"];
[self.window.rootViewController presentViewController:vc animated:YES completion:nil];
我想我理解这个问题的意思是您希望视图控制器出现在您在情节提要中配置的导航控制器的上下文中。在这种情况下,您需要做更多的设置:
在您的情节提要中找到包含具有 "notice" ID 的导航控制器,并为其指定一个情节提要 ID - 可能类似于 "noticeNavigationController"
收到通知后,也从故事板构建导航控制器,并使用您知道如何构建的 "notice" 视图控制器将其设置为根...
// as you have it
UIStoryboard *mainsboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [mainsboard instantiateViewControllerWithIdentifier:@"notice"];
// but now build a navigation controller, too
UINavigationController *navVC = [mainsboard instantiateViewControllerWithIdentifier:@"noticeNavigationController"];
// make your vc the root
navVC.viewControllers = @[ vc ];
// and present** that navigation controller
[self.window.rootViewController presentViewController: navVC animated:YES completion:nil];
**注意,除非您出于某种原因有意进行演示,否则更常见的做法是将应用程序的 rootViewController 设置为 navVC,而不是演示它。
我在用户点击推送通知后设置了一个重定向,它确实有效。然而,该应用程序被重定向到没有导航栏和底部工具栏的视图控制器。下面是我的重定向代码:-
// Did receive notification method here...
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo NS_AVAILABLE_IOS(3_0)
{
NSLog(@"user info1 is %@",userInfo);
[[NSNotificationCenter defaultCenter] postNotificationName:@"NOTIFICATION_RECIEVED"
object:nil
userInfo:nil];
UIStoryboard *mainsboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [mainsboard instantiateViewControllerWithIdentifier:@"notice"];
[self.window.rootViewController presentViewController:vc animated:YES completion:nil];
我想我理解这个问题的意思是您希望视图控制器出现在您在情节提要中配置的导航控制器的上下文中。在这种情况下,您需要做更多的设置:
在您的情节提要中找到包含具有 "notice" ID 的导航控制器,并为其指定一个情节提要 ID - 可能类似于 "noticeNavigationController"
收到通知后,也从故事板构建导航控制器,并使用您知道如何构建的 "notice" 视图控制器将其设置为根...
// as you have it UIStoryboard *mainsboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UIViewController *vc = [mainsboard instantiateViewControllerWithIdentifier:@"notice"]; // but now build a navigation controller, too UINavigationController *navVC = [mainsboard instantiateViewControllerWithIdentifier:@"noticeNavigationController"]; // make your vc the root navVC.viewControllers = @[ vc ]; // and present** that navigation controller [self.window.rootViewController presentViewController: navVC animated:YES completion:nil];
**注意,除非您出于某种原因有意进行演示,否则更常见的做法是将应用程序的 rootViewController 设置为 navVC,而不是演示它。