ios - Can't change size and position for UIView loaded from xib -
i have uicollectionview , dark grey area on top. in grey area needed put tabs uiview. because i'll need outlets, uiview has own tabsviewcontroller. no matter do, view trying add stays in top left corner strange offset , size.
i tried change size , position or put on top of different views — gives same visual result.
auto layout on. view should have height of 72 , 100% width.

tabsviewcontroller *tabs = [[tabsviewcontroller alloc] init]; cgsize screen = // returns correct screen size tabs.view.frame = cgrectmake(0, 0, screen.width, 72); [self.collectionview addsubview:tabs.view]; i tried call code above multiple places, including viewdidload, viewwillappear, viewdidlayoutsubviews , viewdidappear.
in auto layout have change constrains instead of frame. connect view constrains code nslayoutconstrains , try changing constrains set view programatically.
connect constraint of view in ib code iboutlet properties
example :
@property (weak, nonatomic) iboutlet nslayoutconstraint *width; @property (weak, nonatomic) iboutlet nslayoutconstraint *hieght; @property (weak, nonatomic) iboutlet nslayoutconstraint *topspace; @property (weak, nonatomic) iboutlet nslayoutconstraint *horizontalcenter; @property (weak, nonatomic) iboutlet nslayoutconstraint *leftspace; @property (weak, nonatomic) iboutlet nslayoutconstraint *rightspace; @property (weak, nonatomic) iboutlet nslayoutconstraint *verticalcenter; and change there values as:
self.width.constant=current_value_for_constraint; self.hieght.constant=current_value_for_constraint; self.topspace.constant=current_value_for_constraint; self.horizontalcenter.constant=current_value_for_constraint; self.leftspace.constant=current_value_for_constraint; self.rightspace.constant=current_value_for_constraint; self.verticalcenter.constant=current_value_for_constraint;

Comments
Post a Comment