#import "MyViewController.h"
@implementation MyViewController
@synthesize menuView, gameView, helpView, optionsView, gameButton, helpButton, optionsButton;
- (void) viewDidLoad {
[self setView:menuView];
}
- (IBAction)gotoGame {
[UIView beginAnimations:@"buttonSlide" context: nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationDidStopSelector:@selector(animationDidStop)];
gameButton.center = CGPointMake(104,1000);
[UIView commitAnimations];
}
- (IBAction)gotoHelp {
[self setView:helpView];
}
- (IBAction)gotoOptions {
[self setView:optionsView];
}
- (void)animationDidStop {
NSLog(@"why is this not working?");
[self setView:gameView];
}
@end
Wasn't sure what would be helpful so I included the whole .m file. Anyway, I'm new to iPhone app development and I'm struggling to finish up my animation. The animation itself works perfectly but the method animationDidStop refuses to get called..even though I use setAnimationDidStopSelector just as it's shown in the documentation. I know the view change works because when I put it after the animation in gotoGame {} it switches, however this makes it so the animation is not shown.
Could somebody help me either get that method called after the animation stops or with a timer to call it after the necessary time? (I tried this method as well and had no luck).
Not only does [UIView setAnimationDelegate:self] have to be called, but if the calling method of the animation is static the delegate also has to be static. Most examples use non-static methods to call the animations, so this may perplexing (it was for me at least) if you are using static methods to animate.
add [UIView setAnimationDelegate:self];