简体   繁体   English

导航控制器中的iOS ScrollView +页面控制器:如何更改每个页面的导航栏标题?

[英]iOS ScrollView + Page Controller inside Navigation Controller: How to change title of the Navigation Bar for each page?

In my app I have a UINavigationController. 在我的应用程序中,我有一个UINavigationController。 One of the views in the NavigationController has a ScrollView + Page Control combo. NavigationController中的视图之一具有ScrollView + Page Control组合。 There are 3 pages in the scroll view. 滚动视图中有3页。 Is there any way to change the title of the NavigationBar according to the scroll view page on which you currently are? 有什么方法可以根据当前所在的滚动视图页面来更改NavigationBar的标题?

I tried these two methods found in other posts: 我尝试了在其他帖子中找到的这两种方法:

self.navigationItem.titleView self.navigationItem.titleView

and

viewController.title = @"title text"; viewController.title = @“标题文字”;

but they didn't work. 但是他们没有用。 And on top of all I'm not even sure where in the code I should change the title. 最重要的是,我什至不知道应该在代码中的哪个位置更改标题。 In the change page function ? 在更改页面功能?

Any help is greatly appreciated. 任何帮助是极大的赞赏。

I solved the problem by doing self.title = @"title". 我通过执行self.title = @“ title”解决了这个问题。 I put the code in the method which takes care of scrolling around the pages. 我将代码放在该方法中,该方法负责在页面之间滚动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM