我在尝试取消隐藏应用中的导航栏时遇到问题。我有一个在UIViewController中创建的UIPageViewController,如下所示:
//Hide the bar
self.navigationController.navigationBar.hidden=YES;
// Create page view controller
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pageViewController.dataSource = self;
UIPageControl *pageControl = [UIPageControl appearance];
pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
pageControl.currentPageIndicatorTintColor = [UIColor colorWithRed:229/255.0 green:145/255.0 blue:217/255.0 alpha:1];
pageControl.backgroundColor = [UIColor whiteColor];
//Call our helper method
StickerContentViewController *startingViewController = [self viewControllerAtIndex:0];
//Need to pass the first one, don't put them all in here
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
//setup
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
当我使用[self.navigationController popViewControllerAnimated:YES];
弹出UIViewController(包含UIPageViewController的那个)时,我无法取消导航栏以取消隐藏前一个屏幕。我尝试在viewWillDisappear,viewDidDissappear中放置self.navigationController.navigationBarHidden=NO;
。我也尝试将它放在内容视图控制器中,但仍然没有运气。有人能给我一个指针,指出我在这里做错了吗?
答案 0 :(得分:0)
修正了它,只是发布以防其他人有问题。我应该使用self.navigationController.navigationBar.hidden=YES;
时使用self.navigationController.navigationBarHidden=YES;
。不确定有什么区别。无论如何,我隐藏了viewDidLoad中的栏,并在viewWillDisappear中取消隐藏它,现在它可以正常工作。谢谢你们