Jeffrey Aylesworth
Jeffrey Aylesworth

Reputation: 8480

Recreating UIView.frame to move it

I have a UIImageView object created in IB, and has an outlet. I want to move it, but only change the y value, so I have:

CGFloat x, w, h;
x = image.frame.origin.x;
w = image.frame.size.width;
h = image.frame.size.height;
image.frame = CGRectMake(x, /*formula to figure out new y value*/, w, h);

When this runs, the image simply disappears. Do I have to run some code or something to make it display again? I've used this method before to completely move stuff to new positions when the ipod is rotated, and it worked.

Using NSLog(), I know that the y value it is getting is correct and not off the screen.

Upvotes: 0

Views: 414

Answers (1)

fbrereto
fbrereto

Reputation: 35925

The above code looks OK, so there has to be something more to the problem. Have you tried getting the frame back out of the UIView once you've reset it to make sure the value is still what you'd expect? Also, is there any code anywhere else in your app that is altering state for this UIView (frame, opacity, size, etc.)?

Upvotes: 1

Related Questions