iOS 11更喜欢大型标题直到滚动才更新

问题描述:

我用包装在UINavigationController中的UITableView实现了一个基本的UIViewController。我将 prefersLargeTitles 设置为true:

I implemented a basic UIViewController with a UITableView that's wrapped in a UINavigationController. I set prefersLargeTitles to true:

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    navigationController?.navigationBar.prefersLargeTitles = true
    navigationItem.title = "Coffees"
}

但是,标题一直很小,直到我滚动视图为止,此时它会放大。我尝试将调用移到创建UINavigationController的位置,但是没有任何效果。我确定在设置 prefersLargeTitles 时,navigationController不会为零。

However, the title stays small until I scroll the view, at which point it enlarges. I tried moving that call to where I create the UINavigationController, but there was no effect. I am sure the navigationController is not nil when I set prefersLargeTitles.

我是否应该在其他地方更新该属性?还是应该提交雷达?

Should I be updating that property elsewhere? Or should I file a Radar?

更新:

如果我的视图包含 UITableView 或本身就是 UITableViewController

This only seems to happen if my view contains a UITableView or is itself a UITableViewController

我遇到了同样的问题。尽管您没有使用情节提要,但我希望这可以对某人有所帮助。我在其中嵌入了TableViewController的导航控制器(不是View Controller)选中了首选大标题。导航控制器转动并具有大标题后,所有View Controller均应正常工作。

I had the same problem. Although you are not using Storyboards but I hope this could help someone. I checked "Prefer Large Titles" for the Navigation Controller (not the View Controller) I embedded my TableViewController in. All the View Controllers after the Navigation Controller turned and had large titles, and it should work.