0
我在计算UINavigationController的实际结构时遇到了一些麻烦。我想约束它,以便它的视图匹配顶层控制器视图的首选大小。将UINavigationView的大小限制为其当前呈现的控制器的大小?
喜欢的东西:
navController.view.heightAnchor.constraint(equalTo: navController.topViewController?.view.heightAnchor).isActive = true
给我的错误:
*** Terminating app due to uncaught exception 'NSGenericException',
reason: 'Unable to activate constraint with anchors
<NSLayoutYAxisAnchor:0x600000472e00 "UILayoutContainerView:0x7f9f01d14310.top">
and <NSLayoutYAxisAnchor:0x608000270ac0 "UIView:0x7f9f01d182b0.top">
because they have no common ancestor. Does the constraint or its anchors
reference items in different view hierarchies? That's illegal.'
显然顶部控制器的观点是在不同的层次。这怎么可能?我如何实现创建非全屏UINavigationController的目标?请不要暗示将子控制器的下半部分设置为空白等等。
你如何设置'navController.topViewController?.view.heightAnchor'? – DonMag
这是孩子的意见决定其高度。 – GoldenJoe
所以...你的导航控制器的根视图控制器有一个'.height'约束的子视图?在哪里/如何设置高度限制? – DonMag