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 selec开发者_JAVA百科t this the screen flips and I can make notes.
When I turn iPhone to landscape mode, this button disappears completely.
Any ideas?
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.
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.
精彩评论