views:

135

answers:

1

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.

+1  A: 

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.)?

fbrereto
2009-09-01 15:03:34.382 race[58638:20b] Location: 248.000000,4294967296.000000, 60.000000,720.000000Ah... it's taking the wrong type. How do I typecast that? Like this?: (CGFloat)(y value)
Jeffrey Aylesworth
Tried this, and it still gave the wrong value.
Jeffrey Aylesworth
Based on the result (4294967296) it would seem there's a signed/unsigned casting problem in your formula for calculating y.
fbrereto
Yup, that appears to be it. The number I was generating y from was an unsigned int. Changing that to int, it worked fine.Thank you
Jeffrey Aylesworth