UIImageview改变中心后不会更新
我正在尝试创建一个小型增强现实应用程序,在其中将图像移动到相机捕获的顶部。所以我唯一改变的是 UIImageview 的中心:
[imageView1 setCenter:CGPointMake(x-16, 240)];
中心被更新,但屏幕上图像的位置保持不变。
在中心更新之后,这被称为:
[self.imageView1 performSelectorOnMainThread:@selector(setImage:) withObject:testImage waitUntilDone:YES];
有趣的是,在第一次迭代中它实际上更新了位置。但只是第一次。 有什么想法吗?
I am trying to create a small augmented reality application where I move an image on top of the camera capture. So the only thing I change is the center of the UIImageview:
[imageView1 setCenter:CGPointMake(x-16, 240)];
and the center gets updated but the position of the image on the screen stays the same.
after the center update, this gets called:
[self.imageView1 performSelectorOnMainThread:@selector(setImage:) withObject:testImage waitUntilDone:YES];
The funny thing is that in the first iteration it actually updates the position. But only the first time.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
Try:
这篇文章中接受的答案(UIImageView 不响应居中)表明问题是自动布局,这是有道理的。
这篇文章(我可以禁用特定子视图的自动布局吗?运行时?)解释了如何禁用特定元素的自动布局。
另一个答案建议您添加约束(对于 x 和 y),为这些约束创建 IBOutlet 并更新它们以移动 UI 元素。
The accepted answer in this post (UIImageView not responding to centering) suggests that the problem is autolayout, which makes sense.
This post (Can I disable autolayout for a specific subview at runtime?) explains how to disable autolayout for specific elements.
Another answer suggest you add constraints (for x and y), create IBOutlets for these constrataints and update those to move the UI-element.