【问题标题】:UINavigationBar is hidden when app launch with push notification使用推送通知启动应用程序时隐藏 UINavigationBar
【发布时间】:2016-02-03 05:14:18
【问题描述】:

我有一个ViewController。通常我用

启动它
MyBookingDetailedViewController * vcNavigate = [self.storyboard instantiateViewControllerWithIdentifier:@"MyBookingDetailedViewController"];
vcNavigate.bookId = [booking.bookingId intValue];
vcNavigate.status = booking.bookingStatus;

现在我尝试在用户单击pushNotification 时打开它。我所做的是我在didRecieveRemoteNotificationAppDelegate 文件中添加了以下内容。

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;

MyBookingDetailedViewController *booking = (MyBookingDetailedViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"MyBookingDetailedViewController"];
booking.bookId = [notificationId intValue];
booking.status = notificationStatus;

[navigationController pushViewController:booking animated:YES];

但当它出现时,顶部导航栏是隐藏的。我不能回去,它只是视图。

【问题讨论】:

    标签: ios objective-c push-notification


    【解决方案1】:

    您可以将以下代码放入 MyBookingDetailedViewController

    - (void) viewWillAppear:(BOOL)animated {
    
        [super viewWillAppear:animated];
        [self.navigationController setNavigationBarHidden:NO animated:animated];
    }
    

    【讨论】:

    • @Vikita 给出的答案和你的答案有什么区别?它的外观完全复制。
    • 她在将导航栏隐藏为“是”之前编辑了她的答案。我真的很害怕那些在不知道历史的情况下否决你的答案的人。我不复制答案,您可以查看我的历史记录。
    【解决方案2】:

    我找到了如何处理推送通知以加载页面的正确答案。它正在使用NSNotificationCenter

    Application didreceiveRemoteNotification and jumping to a specific view

    【讨论】:

      【解决方案3】:

      请使用下面的代码并在视图中应用此代码,它可能会对您有所帮助..

      [self.navigationController.navigationBar setTranslucent:NO];
      self.extendedLayoutIncludesOpaqueBars=NO;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多