I want to use auto resizing mask in iPhone to adjust view in landscape and portrait mode. The problem is when I apply width spring from开发者_运维百科 Interface builder, the button changes its size proportionally. But when I apply the same spring by code i.e.
[self.view setAutoresizesSubviews:YES];
[testButton setAutoresizingMask:UIViewAutoresizingNone];
[testButton setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
the button doesn't show the same behavior.
Auto resizing applied on button from Interface builder: original button size: 120 width and 37 height landscape mode button: changes size proportionally
Auto resizing applied on button from Code:
original button size: 120 width and 37 height landscape mode button: changes size by keeping same left and right margins in both Portrait and landscape mode.The mask applied from code doesn't seem to work correctly as the size of button created from code comes out to be greater.
My views are complex that is why i don't want to set the frames of each subview on the View.
Anyone with same issue!!!
Thnx for responding guys, by the way I have solved my issue. There was nothing to do with the link with the interface builder. Actually while creating your view without interface builder, if you want the subviews to be auto re-sized; You have to set springs and struts in a single line using the bitwise OR connector. The code I used for re-sizing my view is:
[appLogo setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
Check 2 things. 1. Connection of IBOutlet 2. Also check that you have created the @property of the IBOutlet of view you have created.
Hope this solve the issue.
精彩评论