1

sorry for my english, I have some trouble to animate a view,

I have a button, i want to move the pushView when button press.

this is my code:

- (IBAction)buttonDidClicked:(id)sender {

[UIView animateWithDuration:0.3
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{

                     CGRect frame = self.greenView.frame;
                     frame.origin.x -= 100;
                     self.someView.frame = frame;

                 } completion:^(BOOL finished) {

                 }];
}

It would be work very well here.

but when I change some UI`s property like label.text,

like that:

- (IBAction)buttonDidClicked:(id)sender {

[UIView animateWithDuration:0.3
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{

                     CGRect frame = self.greenView.frame;
                     frame.origin.x -= 100;
                     self.greenView.frame = frame;

                 } completion:^(BOOL finished) {

                     int i = [self.label.text intValue];
                     i++;

                     self.label.text = [NSString stringWithFormat:@"%d", i];
                 }];
}

the pushView will move back to the first place.

I have a video to explain that: http://youtu.be/eJ9CaTkSaPU

the error just happened in iOS 8.1,

it would be work normal in iOS 7.1 or before.

How to solve the issue?

thanks a lot

Harris Fu
  • 21
  • 6
  • Can you show more code about your greenView? Or show something about your storyboard,I test your code with my XCode 6.It works well – Leo Nov 07 '14 at 07:07
  • There are all code here, but i use Xib not storyboard. I will find another Mac to test it. Thank you very much. :) – Harris Fu Nov 07 '14 at 07:43

1 Answers1

0

Answer my self,

the problem is because of the auto layout,

when I disable auto layout,

the problem be solved.

the more datail can reference: Animation Blocks resets to original position after updating text

Community
  • 1
  • 1
Harris Fu
  • 21
  • 6