2

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?

taskinoor
  • 45,586
  • 12
  • 116
  • 142
user480295
  • 21
  • 1

2 Answers2

0

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.

Community
  • 1
  • 1
0

Try:

imageView1.center = CGPointMake(imageView1.center.x-16, 240);
ohho
  • 50,879
  • 75
  • 256
  • 383
  • x is not a coordinate, it's a double value calculated in every iteration. I should've written that in the original post. But anyway, when I write the center coordinates in the console everything is OK. So I am guessing it's a display problem of some sort. – user480295 Oct 19 '10 at 13:27
  • is there a way to refresh an imageview? I tried with [imageView1 setNeedsDisplay]; but this doesn't seem to work.... – user480295 Oct 20 '10 at 14:00