views:

125

answers:

2

Hi! I have a big UIView (.frame == CGRectMake(0, 0, 905, 320) )

currently the left part is shown (that is (0,0,480,320)) and I would like to be able to show the right side on click. I tried to change the UIView's frame to (480,0,905,320) but it does not seem to work.

Does anyone know how to do it?

it is embedded in a window with .frame == (0, 0, 480, 320). Everything is in landscape mode.

A: 

When you change the view's frame, you're moving the view, not the part that's displayed. So you should use (-480, 0, 905, 320).

jtbandes
+1  A: 

You want to set the bounds of your view, not the frame. More specifically, the origin of it's bounds determines the offset for where the view's content should start displaying. That way the view doesn't move at all, just reveals a different chunk of it's content.

The documentation shows this very clearly:

See "The Relationship of the Frame, Bounds, and Center" View Programming Guide for iPhone

ohhorob
Thanks now it does everything as expected... the swapped X,Y coordinates when setting the frame still seems as an Apple bug to me though
dkk