ios - UIView 在呈现其他 View Controller 后重置为初始值

标签 ios iphone core-graphics calayer

在呈现其他 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/

相关文章:

iphone - 如何获取 NSDictionary 中的第一个元素?

iphone - 在启动画面上添加 UIActivityController

ios - Xamarin iOS : Cannot render iOS Storyboard in Visual Studio 2013

ios - 使用 CHCSVParser 解析 NSString 返回 nil

ios - 计算 Metal 内核中的平均值

iphone - 如何从 UINavigationController 堆栈上已有的 UIViewController 调用方法

objective-c - CGLayer绘图随着时间的过去而变慢

iphone - 无法添加圆角半径和阴影

macos - 永久修改 RGB Gamma 表

ios - 无效更新 : invalid number of rows in section 0 UITableView