我有一个UIView
非常简单的约束,作为 a 上的根视图UIViewController
:
此视图有一个子视图,其中包含我在该子视图中的所有 UI 元素。
两种观点都有.translatesAutoresizingMaskIntoConstraints = NO
。没有这个,就会产生不一致的约束,从而导致崩溃。
当我旋转设备时,视图的位置不会移动。它保持与纵向相同的宽度,并且位于框架的左侧。在 lldb 中打印框架证实了这一点。
我需要添加什么来强制前导/尾随/顶部/底部空间约束同时应用于纵向和横向?
我试过手动请求更新,即:
# On the VC
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self.view setNeedsUpdateConstraints];
[self.storyView setNeedsUpdateConstraints];
}
但这没有任何效果。