且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

自动布局、屏幕旋转和 UIView 动画

更新时间:2023-02-02 15:33:43

好的,我找到了解决方案.它并没有解决上述问题,而是找到了另一种解决方法.

Ok, I found a solution. It doesn't fix the above issue, but rather found another way to approach it.

我将约束改为可视格式语言 (VFL) 方法:

I changed my constraints to the Visual Format Language (VFL) method instead:

subBar.filterListView.verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[filtersSubBar][filterListView(0)]" options:0
                                                                                    metrics:nil
                                                                                      views:@{@"filterListView": subBar.filterListView, @"filtersSubBar" : subBar.filtersSubBar}];

我认为问题在于使用导致问题的属性 NSLayoutAttributeTopNSLayoutAttributeRight 等.

I think the issue was using the attributes NSLayoutAttributeTop, NSLayoutAttributeRight, etc that was causing the issue.

Autolayout 无法处理旋转并尝试使用 NSLayoutAttributeTop 而应该将其更改为 NSLayoutAttributeRight 来表达新的方向.我想我们可以手动更改约束.

Autolayout couldn't handle the rotation and trying to use the NSLayoutAttributeTop when it should have been changed to NSLayoutAttributeRight to express the new orientation. I suppose we could manually change the constraint.

似乎 VFL 处理它的方式不同并且不使用属性?

It seems the VFL handles it differently and does not use the attributes?

这感觉好像它要么是一个错误,要么只是 iOS 的一个缺点.

This feels as if its either a bug or just a shortcoming of iOS.