ios - Auto Layout constraint change does not animate -


i learning auto layout animations tutorial

http://weblog.invasivecode.com/post/42362079291/auto-layout-and-core-animation-auto-layout-was

and things working perfect.

when tried use concept in application, trying animate settings screen(a uiview) bottom top,it works great when settings screen empty uiview,

but in case add uilabel subview settings screen, animation vanishes. on removing uilabel form settings screen, animation visible.

here outlets have connected

__weak iboutlet uiview *settingsview; __weak iboutlet nslayoutconstraint *settingsbottomconstraint; __weak iboutlet nslayoutconstraint *settingsviewheightconstraint; 

view did load setup method(setupviews)

-(void)setupviews {     settingsbottomconstraint.constant = - settingsviewheightconstraint.constant;     [settingsview setneedsupdateconstraints];     [settingsview layoutifneeded];     issettingshidden = yes; } 

hide/unhide method

- (ibaction)showsettingsscreen:(id)sender {      if (issettingshidden) {          settingsbottomconstraint.constant = 0;         [settingsview setneedsupdateconstraints];         [uiview animatewithduration:.3 animations:^{             [settingsview layoutifneeded];         }];     }     else{          settingsbottomconstraint.constant = - settingsviewheightconstraint.constant;         [settingsview setneedsupdateconstraints];         [uiview animatewithduration:0.3 animations:^{             [settingsview layoutifneeded];         }];      }     issettingshidden = !issettingshidden; } 

my issue seems similar issue uiview auto layout animation

i found answer.

instead of,

[settingsview layoutifneeded]; 

this line made worked charm,

[self.view layoutifneeded]; 

i suppose need perform layoutifneeded method on parent view not view trying animate.

update: pointed out in comment codyko, required ios 7, ios 10. ios 8 issue not exists.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -