I am trying to create a small augmented reality application where I move an image on top of开发者_如何学Go 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?
Try:
imageView1.center = CGPointMake(imageView1.center.x-16, 240);
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.
精彩评论