Changing view size when orientation changes

Posted by Eyal Redler on Stack Overflow See other posts from Stack Overflow or by Eyal Redler
Published on 2010-03-17T00:35:14Z Indexed on 2010/03/17 0:41 UTC
Read the original article Hit count: 428

Filed under:
|

I want my UIView subclass to behave so that when it is fitted in portrait orientation is has a certain size and another size when fitted in landscape mode.

Is it possible to have the view indicate to the view controller that's resizing it when the orientation changes that it has this "ideal size"?

To clarify, I'm confident that this is not something that can be done with the autoresizing mask. I also thought that sizeThatFits: would be what I need but I didn't see it get called when the orientation changed.

I'm also aware that I can get this done by overriding layoutSubviews of the superview (or maybe some other method of the view controller but I would like to have this behavior embedded in the view to facilitate reuse.

© Stack Overflow or respective owner

Related posts about uiview

Related posts about orientation