gpt4 book ai didi

ios - 单击远程通知后能够重定向到指定 View Controller ,但只有 VC 但没有导航栏

转载 作者:行者123 更新时间:2023-11-29 00:43:51 25 4
gpt4 key购买 nike

我在用户单击推送通知后设置了重定向,并且确实有效。但是,该应用程序重定向到 View Controller ,没有导航栏和底部工具栏。以下是我的重定向代码:-

// 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];

This screenshot showing the notice storyboard properties

This screenshot showing the top navigation item properties

最佳答案

我想我理解这个问题的意思是您希望 View Controller 出现在您在 Storyboard 中配置的导航 Controller 的上下文中。在这种情况下,您需要做更多的设置:

  1. 在您的 Storyboard中找到包含带有“notice”ID 的导航 Controller ,并给它一个 Storyboard ID——可能类似于“noticeNavigationController”

  2. 收到通知后,也从 Storyboard构建导航 Controller ,并使用您知道如何构建的“通知” View Controller 将其设置为根...

    // 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,而不是演示它。

关于ios - 单击远程通知后能够重定向到指定 View Controller ,但只有 VC 但没有导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38885887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com