Reputation: 21593
I have a UIView a
that has autoresizing subviews
enabled. It's size is:
<UIView: 0x7650180; frame = (0 0; 320 394); clipsToBounds = YES; autoresize = LM+RM+H; layer = <CALayer: 0x7650230>>
I have another UIView b
which i added to the view a
. View b
has flexible width/height. When I add it in, I expect it's height to change to 394
, but it remains the same as the in the nib (420
):
<UIView: 0x764f720; frame = (0 0; 320 460); autoresize = LM+W+RM+TM+H+BM; layer = <CALayer: 0x764f320>>
What am I doing wrong?
Thanks
Upvotes: 3
Views: 4180
Reputation: 2593
Autoresizing of subviews works only for subviews already added to a parent view. What should you do:
Only then you will see that subviews are being autoresizes.
Adding subviews after resize will give no effect.
Upvotes: 4
Reputation: 17916
Autoresize only affects subviews when the frame of the parent view changes. If you want your subview to have the same height as the parent view, you'll have to set the height to be equal, either before or after you add it as a subview.
Upvotes: 0