返回导航到根视图控制器后,折叠的大标题导航栏会展开
Collapsed large title navigation bar becomes expanded after back navigation to root view controller
我的 UIViewController 带有垂直 UIScrollView,它以 UIView 作为所有子视图的容器。这是我的 scrollView 和 contentView 约束:
scrollView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
scrollView.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor).isActive = true
scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
contentView.centerXAnchor.constraint(equalTo: scrollView.centerXAnchor).isActive = true
contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor).isActive = true
contentView.topAnchor.constraint(equalTo: scrollView.topAnchor).isActive = true
contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true
当我向下滚动时,我的导航栏会变小,因为它应该是:
然后我单击 tableviewcell,导航到 detailVC 并返回。这就是问题所在。不知何故,我的导航栏变大,直到我向任何方向滚动它,然后它跳转到它的正常状态。为什么会发生这种情况,可能是什么原因?
Here 是我的 ViewController 代码
的要点
谢谢!
我配置了约束并解决了这个问题。
新约束:
scrollView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
scrollView.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor).isActive = true
scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
contentView.topAnchor.constraint(equalTo: scrollView.topAnchor).isActive = true
contentView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor).isActive = true
contentView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor).isActive = true
contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true
// contentView.heightAnchor.constraint(equalTo: scrollView.heightAnchor).isActive = would be true if horizontal
contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor).isActive = true
我的 UIViewController 带有垂直 UIScrollView,它以 UIView 作为所有子视图的容器。这是我的 scrollView 和 contentView 约束:
scrollView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
scrollView.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor).isActive = true
scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
contentView.centerXAnchor.constraint(equalTo: scrollView.centerXAnchor).isActive = true
contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor).isActive = true
contentView.topAnchor.constraint(equalTo: scrollView.topAnchor).isActive = true
contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true
当我向下滚动时,我的导航栏会变小,因为它应该是:
然后我单击 tableviewcell,导航到 detailVC 并返回。这就是问题所在。不知何故,我的导航栏变大,直到我向任何方向滚动它,然后它跳转到它的正常状态。为什么会发生这种情况,可能是什么原因?
Here 是我的 ViewController 代码
的要点谢谢!
我配置了约束并解决了这个问题。
新约束:
scrollView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
scrollView.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor).isActive = true
scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
contentView.topAnchor.constraint(equalTo: scrollView.topAnchor).isActive = true
contentView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor).isActive = true
contentView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor).isActive = true
contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true
// contentView.heightAnchor.constraint(equalTo: scrollView.heightAnchor).isActive = would be true if horizontal
contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor).isActive = true