views:

38

answers:

2

Hi,

In my application, I have a series of tables which leads up to an image. In portrait mode, there is a button in the bottom right hand corner, and when I select this the screen flips and I can make notes.

When I turn iPhone to landscape mode, this button disappears completely.

Any ideas?

+1  A: 

That's probably because the button is just off screen. You need to constrain it in Interface Builder (on the size/layout tab of the Inspector Window) or use setFrame: to reposition it when the app rotates and then again when it rotates back.

Anytime the device rotates, it will reposition items based on either code or how it is constrained in Interface Builder. If you don't control the repositioning, then it might give the appearance that it magically disappeared.

iWasRobbed
A: 

If you're setting up the view in code, use the autoresizingMask property. This is what is being set by the constraints in Interface Builder. However, it's a little backwards from what you see in Interface Builder. If you want it to stick to the lower-right corner, set view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin (which is equivalent to enabling the springs on the right and bottom in IB. Flexible width and height, on the other hand, work as you would expect.

As long as the superview has autoresizesSubviews set to YES (the default), it will reposition automatically when you rotate.

Brian