导航栏中的从大标题到小标题的切换并不流畅iOS 13 [英] Large title to small title switch in navigation bar is not smooth iOS 13, sticky
问题描述
我有一个UINavigationController
,其默认值为navigationBar.prefersLargeTitles = true
.
I have a UINavigationController
with default value of it's navigationBar.prefersLargeTitles = true
.
当我push
进入新场景时,我将其切换为false
,通过将其更改为viewWillDisappear
来调用它(DetailsViewController
).
I am switching that to false
when I push
into a new scene lets call it (DetailsViewController
), by changing it into the viewWillDisappear
.
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.navigationBar.prefersLargeTitles = false
}
现在在DetailsViewController
中,我正在使用willMove(to parent:)
.
Now in DetailsViewController
I am using willMove(to parent:)
.
override func willMove(toParent parent: UIViewController?) {
navigationController?.navigationBar.prefersLargeTitles = true
}
要过渡回大标题.
考虑 iOS 12 是正确的行为,请观察所附的快照,了解 iOS 13 的运行方式和 iOS 12 的运行方式.
Observe the attached snapshots of how iOS 13 doing it with how iOS 12 is doing it, considering iOS 12 is the correct behavior.
iOS 13 :
iOS 12 :
推荐答案
您所做的总是错误的.您应该将导航栏的prefersLargeTitles
设置为true
一次,再也不要触摸它.
What you're doing was always wrong. You should set prefersLargeTitles
to true
once for the navigation bar and never touch it again.
更改每个视图控制器对大标题所做的操作的方法是,该视图控制器将其自己的navigationItem
(在其viewDidLoad
中)设置为具有所需的largeTitleDisplayMode
.所以如果第一个v.c. .always
,第二个具有.never
,一切都会变得顺畅.
The way to change what each view controller does about large titles as it appears is that that view controller sets its own navigationItem
(in its viewDidLoad
) to have the desired largeTitleDisplayMode
. So if the first v.c. has .always
and the second has .never
everything will be smooth.
这篇关于导航栏中的从大标题到小标题的切换并不流畅iOS 13的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!