ios - Animation Blocks resets to original position after updating text -


i'm testing apps release of ios 8. noticed after performed animation block, animation resets if update text of label. ran simple example 1 method shown below. running example results in following:

  • clicking mybutton first time- animation runs resets when label text changed.
  • clicking mybutton second time - animation runs not reset original position.

it seems happens because label text doesn't change. if remove line updating text, stops animation resetting @ end.

i fix when method runs, label text can updated without resetting animation.

- (ibaction)move:(id)sender {  [uiview animatewithduration:0.4 delay:0.0                  options:uiviewanimationoptionbeginfromcurrentstate                  animations:^{                      self.mybutton.center = cgpointmake(200, 300);                  }completion:^(bool finished){                       if(finished){                          self.mylabel.text=@"moved";                      }                   }]; } 

this problem can caused having auto layout set on uiview. strictly speaking, if you're using auto layout, shouldn't animate absolute position of objects -- should animate constraints instead.

changing label text once animation underway triggers layout refresh, , ios shuffles around comply original view constraints. (i suspect behavioural change ios7).

quick fix: un-check auto layout on view, , should work expected.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -