2016-07-21 6 views
0

ユーザーがタブバーボタンをタップしたときにカスタムタブバーアニメーションを作成しようとしています。私はここにUITabBarControllerDelegateiOS/Objective c - UITabBarControllerDelegate - カスタムタブアニメーション代理人が呼び出されない

を実装UITabBarControllerのサブクラスを実装している

は、移行を担当するデリゲートメソッドが呼び出さされていないいくつかの理由のための.m

#import "MYCustomTabBarControler.h" 


@interface MYCustomTabBarControler() 

@end 

@implementation MYCustomTabBarControler 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    self.delegate = self; // I set the delegate as self 

} 


#pragma mark - UITabBarControllerDelegate 

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

    //This is called so I know the delegate is working 
    NSLog(@"The tabBarController delegate is set and working"); 
    return YES; 
} 

//This delegate method is never called 
- (id<UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController 
      UIViewControllerAnimatedTransitioning:(UIViewController *)fromVC 
              toViewController:(UIViewController *)toVC { 


    MYBarTransition *animator = [MYBarTransition new]; 
    return animator; 

} 

//This delegate method is never called 
- (id<UIViewControllerInteractiveTransitioning>)tabBarController:(UITabBarController *)tabBarController 
        interactionControllerForAnimationController:(id<UIViewControllerAnimatedTransitioning>)animationController { 

    MYBarTransition *animator = [MYBarTransition new]; 
    return animator; 
} 

です。私はdocsを読んだので、呼び出されない理由は見当たりません。

私は正しく私のデリゲートを設定し、それは私がここで行方不明です何shouldSelectViewController方法

を実装することにより、作業 で確認していますか?

+0

いつ呼び出されると思いますか? – beyowulf

+0

ユーザがタブバーボタンをタップしたときに呼び出されるべきですか? – Zigglzworth

+0

ユーザーがタブバーボタンをタップしたときに呼び出されると期待しますが、 – Zigglzworth

答えて

3

私はあなたが達成しようとしているものに対して間違った委任方法を使用していると思います。試してみてください:

- (nullable id <UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController 
      animationControllerForTransitionFromViewController:(UIViewController *)fromVC 
               toViewController:(UIViewController *)toVC; 

これは、ユーザーが別のタブをタップすると呼び出されます。

+0

LOLではありません。はい。私は数時間、恥ずべきで私の頭を横にして行くつもりです – Zigglzworth

関連する問題