ios - NSConstraint.constant checking its value after setting to avoid animating view again -


i have uitextfield (email) , uilabel (email error messages) - see image

enter image description here

when enter invalid email, animate in uilabel in changing constraint (linked iboutlet - default setting 22 in ib overridden in viewdidload 0) 0 22. works perfectly.

when enter valid email, reverse happens. works perfectly.

i'm having trouble finding way not animate uilabel in even if there code below:

   self.usernameerrormessage.text = @"invalid email";      nslog(@"before constant: %f", self.emailerrormessagelabelheightconstraint.constant);     nslog(@"before email textfield height: %f", self.usernameerrormessage.bounds.size.height);      if (self.emailerrormessagelabelheightconstraint.constant != 22) {          self.emailerrormessagelabelheightconstraint.constant = 22;         [self.view setneedsupdateconstraints];          [self.view layoutifneeded];         [uiview animatewithduration:0.5 animations:^{              nslog(@"after constant: %f", self.emailerrormessagelabelheightconstraint.constant);             nslog(@"after email textfield height: %f", self.usernameerrormessage.bounds.size.height);              [self.view layoutifneeded];         }];     } 

output of nslog after running first time & entering invalid email

2014-03-19 14:10:44.085 login[21743:60b] before constant: 0.000000 2014-03-19 14:10:44.086 login[21743:60b] before email textfield height: 0.000000 2014-03-19 14:10:47.341 login[21743:60b] after constant: 22.000000 2014-03-19 14:10:47.341 login[21743:60b] after email textfield height: 22.000000 

clicking textfield run code above again (this time expect animation not happen since error message uilabel showing... animates in since constant when checked in if statement 0.000000 still...

output of second run

2014-03-19 14:15:01.074 login[21743:60b] before constant: 0.000000 2014-03-19 14:15:01.074 login[21743:60b] before email textfield height: 0.000000 2014-03-19 14:15:01.865 login[21743:60b] after constant: 22.000000 2014-03-19 14:15:01.866 login[21743:60b] after email textfield height: 22.000000 


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -