Frame of UIView doesn't change after auto pin edges to SuperView (with PureLayout - ObjectiveC)

404 Views Asked by At

My parent UIView has a frame (0,0,1024,768).

My subview with the original frame is (0,0,0,0). I add the subview to the parent view and then use PureLayout to spread the subview to fullscreen of the parent view as follow:


CGRect f1 = mySubView.frame; //- (0,0,0,0)

[myParentView addSubView:mySubView];
[mySubView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero];

CGRect f2 = mySubView.frame; //- (0,0,0,0)

After auto-pin edges to superview, why my subview doesn't change?

Note: I am using ObjectiveC and PureLayout

1

There are 1 best solutions below

0
chipbk10 On

Because I need to call method "layoutIfNeeded" after adding the subview:

[myParentView addSubView:mySubView];
[mySubView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero];
[myParentView layoutIfNeeded];