在呈现其他 View Controller 后,UIView 的框架和位置属性重置为初始值。
- (IBAction)moveClicked:(UIButton *)sender {
self.imvOriginal.center = CGPointMake(self.imvOriginal.center.x + 200, self.imvOriginal.center.y + 200);
}
- (IBAction)showClicked:(UIButton *)sender {
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
TopViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"topViewController"];
[self presentViewController:vc animated:YES completion:nil];
}
topViewController关闭后,imvOriginal的center属性会自动重置。 事实上,当打开 topViewController 时,这个属性会被重置。
我不会使用自动约束,因为我应该使用平移、捏合、旋转手势来实现 ImageView 的移动、缩放、旋转。此功能更改 ImageView 图层的位置、affineTransform 属性。
我应该如何解决这个问题?
最佳答案
您看到的问题是由自动布局引起的。即使你没有为 View 设置约束,如果自动布局打开(默认情况下),系统也会为你添加约束。如果您想对 Storyboard 中的某些 View 使用自动布局,而不是对另一个特定 View 使用自动布局,则应在代码中创建该 View 。
关于ios - UIView 在呈现其他 View Controller 后重置为初始值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26678364/