UiPageController和NavigationBar

时间:2014-01-03 13:02:33

标签: ios uinavigationcontroller uipageviewcontroller

我的问题是没有显示控制器中第一个视图的导航栏标题。 对于下一个项目显示文本。 我的代码:

ViewControllerEvent *initialViewController = [self viewControllerAtIndex:self.index];
NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];
[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

和View Controller代码:

- (void)viewDidAppear:(BOOL)animated{
    self.navigationController.navigationBar.topItem.title = [self.event objectForKey:@"name"];
}

1 个答案:

答案 0 :(得分:0)

试试这个

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    self.navigationController.title = [self.event objectForKey:@"name"];
}