0

I want to click _transitButton to call onTransitButtonDidClick to move _rightView. The problem is the button cannot do as I set self.transitButton.frame = CGRectMake(0, 0, 30, 20);.

update:

_transitButton original frame is (0,280,30,20) the result is, the button move from the original frame to (0,0,30,20), but quickly move back to original point. why it went back?

why and how to solve this issue?

- (IBAction)onTransitButtonDidClick:(id)sender {
    [UIView animateWithDuration:0.3
                      delay:0.0
                    options:UIViewAnimationCurveEaseInOut
                 animations:^{
                     [_rightView setFrame:CGRectMake(40,0,320,548)];
                     [_transitButton setFrame:CGRectMake(0,0,30,20];
                 }
                 completion:nil];
}
Olotiar
  • 3,225
  • 1
  • 18
  • 37
CCC
  • 2,164
  • 8
  • 27
  • 47
  • on click you want to move a button in an animation and be able click it AGAIN in the animation which would start the animation over again? – Daij-Djan Nov 17 '12 at 11:58
  • nope,I just click the button once, as the _rightView has moved in animation which covered the button. – CCC Nov 17 '12 at 16:05
  • I dont get ^^ who calls inTransitButtonDidClick .. you said the button should – Daij-Djan Nov 17 '12 at 16:09
  • It's IBAction. when you click _transitButton, the function is called. – CCC Nov 18 '12 at 01:52
  • Just FYI. You really should have a tag here for Objective-C. Really you should have one for Cocoa-Touch too, but at the very least Objective-C. Thanks, and good luck. :) – Josiah Nov 18 '12 at 03:41
  • thanks buddy. just I think is not tag problem. – CCC Nov 18 '12 at 07:17
  • AH now with your update I can follow a bit. @AceLegend is right btw. – Daij-Djan Nov 18 '12 at 10:00

1 Answers1

3

you are using autolayout in your xib and constraints keep the button in place. with animation it appears to work because the constraints arent evaluated for animations.

so either turn off AUTOLAYOUT for this xib or modify the appropriate constrains.

(I tried this with a small sample app and that's it.)

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • you are right. it's caused by autolayout. and I unchecked it from nib file it okay. – CCC Nov 18 '12 at 10:25