我想創建一個自定義的tabbar動畫,當用戶點擊選項卡欄按鈕。iOS/Objective c - UITabBarControllerDelegate - 自定義選項卡動畫代理不叫
我已經實現了實現UITabBarControllerDelegate
這裏是.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;
}
出於某種原因,負責過渡的委託方法是不叫的UITabBarController的子類。我已閱讀docs,並且看不到任何他們不會被調用的原因。
我已正確設置我的委託,並證實了它是 通過實現shouldSelectViewController方法
缺少什麼我在這裏工作?
你預計什麼時候叫它? – beyowulf
當用戶點擊標籤欄按鈕時不應該調用它嗎? – Zigglzworth
我希望當用戶點擊標籤欄按鈕時會調用它..但它不是 – Zigglzworth