问题描述
我遇到一个奇怪的问题:
I ran into a strange problem:
- 我有两个视图控制器-列表和详细信息.
- 当我从列表"中按详细信息"时,导航栏处于折叠模式.
- 要使标题显得较大,我必须向下滚动.
ListViewController:
ListViewController:
...
override func viewDidLoad() {
super.viewDidLoad()
setupNavigationBar()
}
private func setupNavigationBar() {
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.largeTitleDisplayMode = .never
}
...
DetailViewController:
DetailViewController:
...
override func viewDidLoad() {
super.viewDidLoad()
setupNavigationBar()
}
private func setupNavigationBar() {
title = "Bangkok ⇄ Phuket"
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.largeTitleDisplayMode = .always
}
...
经过一番调查,我发现该错误仅在我在标题中放入某些字符时出现:
After some investigation, I found out that the bug oocurs only when I put certain characters in the title:
- 标题为曼谷→普吉岛"时,一切按预期进行
- 当标题为曼谷⇄普吉岛"时,被推送的控制者的标题将被折叠
你们知道标题中字符的限制是什么,或者有什么解决方法的想法吗?谢谢您的帮助,不胜感激
Do you guys know what are the restrictions for characters in title, or any ideas how to solve it? Thank you, any help much appreciated
推荐答案
使用navigationController?.navigationItem.largeTitleDisplayMode = .always代替navigationItem.largeTitleDisplayMode = .always始终为我解决了该问题.
Use navigationController?.navigationItem.largeTitleDisplayMode = .always instead of navigationItem.largeTitleDisplayMode = .always fixed the issue for me.
navigationController?.navigationBar.prefersLargeTitles = true
navigationController?.navigationItem.largeTitleDisplayMode = .always
此问题表明viewController的navigationController.navigationItem和self.navigationItem之间存在差异.请注意使用它.
This issue indicates that there are differences between navigationController.navigationItem and self.navigationItem of viewController. Be aware on using it.
这篇关于大标题最初在推送后折叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!