私の viewDidLoad メソッドでは、ビューの左側、画面外にボタンを配置します。
次に、次の 2 つの方法を使用してアニメーション化します。
-(void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self showButton];
}
そして方法:
-(void) showButton {
[myButton setTitle:[self getButtonTitle] forState:UIControlStateNormal];
// animate in
[UIView beginAnimations:@"button_in" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDone)];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationBeginsFromCurrentState:YES];
[myButton setFrame:kMyButtonFrameCenter]; // defined CGRect
[UIView commitAnimations];
}
ボタンはすぐに表示され、アニメーションは表示されません。さらに、animationDone セレクターがすぐに呼び出されます。
ボタンが画面にアニメーション化されないのはなぜですか?
編集:これは、viewDidAppear でアニメーションを開始しようとすることに関係している必要があります...