使用推送通知启动应用程序时隐藏 UINavigationBar
UINavigationBar is hidden when app launch with push notification
我有一个ViewController
。通常我用
启动它
MyBookingDetailedViewController * vcNavigate = [self.storyboard instantiateViewControllerWithIdentifier:@"MyBookingDetailedViewController"];
vcNavigate.bookId = [booking.bookingId intValue];
vcNavigate.status = booking.bookingStatus;
现在我尝试在用户单击 pushNotification
时打开它。我所做的是在 AppDelegate
文件的 didRecieveRemoteNotification
中添加以下内容。
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];
但是出现的时候,顶部导航栏是隐藏的。我不能回去,它只是视图而已。
您可以将以下代码放入 MyBookingDetailedViewController
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
请使用下面的代码并在视图中应用此代码,它可能对您有所帮助..
[self.navigationController.navigationBar setTranslucent:NO];
self.extendedLayoutIncludesOpaqueBars=NO;
我找到了如何处理推送通知以加载页面的正确答案。它正在使用 NSNotificationCenter
Application didreceiveRemoteNotification and jumping to a specific view
我有一个ViewController
。通常我用
MyBookingDetailedViewController * vcNavigate = [self.storyboard instantiateViewControllerWithIdentifier:@"MyBookingDetailedViewController"];
vcNavigate.bookId = [booking.bookingId intValue];
vcNavigate.status = booking.bookingStatus;
现在我尝试在用户单击 pushNotification
时打开它。我所做的是在 AppDelegate
文件的 didRecieveRemoteNotification
中添加以下内容。
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];
但是出现的时候,顶部导航栏是隐藏的。我不能回去,它只是视图而已。
您可以将以下代码放入 MyBookingDetailedViewController
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
请使用下面的代码并在视图中应用此代码,它可能对您有所帮助..
[self.navigationController.navigationBar setTranslucent:NO];
self.extendedLayoutIncludesOpaqueBars=NO;
我找到了如何处理推送通知以加载页面的正确答案。它正在使用 NSNotificationCenter
Application didreceiveRemoteNotification and jumping to a specific view