使用推送通知启动应用程序时隐藏UINavigationBar

时间:2016-02-03 05:14:18

标签: ios objective-c push-notification

我有ViewController。通常我会用

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

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

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

但是当它出现时,顶部导航栏被隐藏。我不能回去,它只是查看。

4 个答案:

答案 0 :(得分:0)

您可以将以下代码放在 MyBookingDetailedViewController

- (void) viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

答案 1 :(得分:0)

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

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

答案 2 :(得分:0)

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

Application didreceiveRemoteNotification and jumping to a specific view

答案 3 :(得分:-3)

您可以将以下代码放在 MyBookingDetailedViewController

如果要显示导航栏,则需要将hidden设置为NO

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