2

UITabBarViewController が pushViewController を実行するときに UINavigationController と同じアニメーションを実行しようとして問題が発生しています。

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {

UIViewController *currentVC = [tabBarController selectedViewController];
if (currentVC == viewController) 
    return NO;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
UIModalTransitionStyle transition = UIModalTransitionStyleFlipHorizontal;
[UIView setAnimationTransition:transition forView:tabBarController.view cache:YES];
[currentVC viewWillAppear:YES];
[viewController viewWillDisappear:YES];
[viewController viewDidDisappear:YES];
[currentVC viewDidAppear:YES];
[UIView commitAnimations];
return YES;}

次のコードは、タブを切り替えるときにアニメーションを実行します。

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {

UIViewController *currentVC = [tabBarController selectedViewController];
if (currentVC == viewController) 
    return NO;

[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:tabBarController.view cache:YES];
[currentVC viewWillAppear:YES];
[viewController viewWillDisappear:YES];
[viewController viewDidDisappear:YES];
[currentVC viewDidAppear:YES];
[UIView commitAnimations];

return YES;}

上記のコードを変更して、viewController をナビゲーション コントローラーにプッシュするのと同じように、正しいアニメーションからスライドを実行するにはどうすればよいですか?

4

1 に答える 1

1

このリンクを見てみましょう: http://haveacafe.wordpress.com/2009/04/06/animated-transition-between-tabbars-view-on-iphone/

アイデアは、タブ バー コントローラーのデリゲート メソッドを使用し、特定のアニメーション クラス CATransition を使用する必要があるということです (ビュー間で「遷移」しているため)。アニメーションのタイプ/サブタイプについては、 CATransition のドキュメントを参照してください。おそらく、左または右のサブタイプを持つタイプのプッシュが必要になるでしょう。

于 2011-04-19T15:02:32.373 に答える