Reputation: 3780
I tried several solutions found on other posts but still having problems to autoresize subviews when device rotation. My layout (IB) has three views and only apply resize to current view. If then, after rotating device, view is shown, was not resized and remains at previous dimensions. I set autoresize subviews and its mask... What am I doing wrong or missing? any help would be appreciated, thank you!
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view setAutoresizesSubviews:YES];
[self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[vistaSocial setAutoresizesSubviews:YES];
[vistaSocial setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[vistaB setAutoresizesSubviews:YES];
[vistaB setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
Upvotes: 4
Views: 3982
Reputation: 51
You can set Autoresize property with the help of Nib file. Can you please check once you set it properly from NIB file?
Upvotes: 2
Reputation: 766
I think you are not using a proper resizing properties on xib file. As per my understanding, you must have added 2-3 views on current controller; but auto-resizing is getting wrong somewhere. Try one by one and with a correct set. You can share any screen shot for better understanding, if i am predicting it wrong.
Upvotes: 2
Reputation: 961
For a given view to adjust its size upon device rotation, it is its superview that needs to have its autoresizesSubviews
property set to YES
. (It is not clear from your code fragment what your view hierarchy is.) Try changing
[vistaB setAutoresizesSubviews:YES];
to
[vistaB.superview setAutoresizesSubviews:YES];
Upvotes: 1