Hug*_*ugo 10 iphone objective-c uiviewcontroller ios
我在Xcode5故事板,我有一个UITabbarController,有一个UINavigationController链接到一个UIViewController.从最后一个开始UIViewController(UIPageviewController并UITableViewController在各自的类中以编程方式创建.请参见屏幕截图.
问题是设置更改UINavigationController页面时的标题UIPageViewController.我想标题,以反映@property对UITableViewController类,但我不知道如何做到这一点.
我已经尝试过使用一个NSNotification集合,UITableViewController但是没有方法在每次用户向左或向右滑动另一个页面时调用(使用滚动类型时).我想如果我有一个地方放置NSNotification它,以便每次用户更改页面时它被调用它解决了我的问题.
希望有人可以给我一个指针,在哪里查看或使用什么方法或委托.
Ben*_*ton 12
我必须在我正在处理的应用程序中完成此操作.
首先确保您已将self.pageViewController.delegate设置为self.
这是我做的:
// Notice when the pageviewcontroller finishes animating between pages.
- (void)pageViewController:(UIPageViewController *)pageViewController
didFinishAnimating:(BOOL)finished
previousViewControllers:(NSArray *)previousViewControllers
transitionCompleted:(BOOL)completed {
// .viewControllers[0] is always (in my case at least) the 'current' viewController.
UIViewController* vc = self.pageViewController.viewControllers[0];
self.navigationItem.title = vc.navigationItem.title;
}
Run Code Online (Sandbox Code Playgroud)
'秘密'是(至少在我所拥有的全屏大小页面的简单滑动 - 左右情况下)self.pageViewController.viewControllers [0]是'当前'页面.
要使用您的属性而不是navigationItem标题,只需将最后一行更改为self.navigationItem.title =((MyViewController*)vc).myProperty;