【发布时间】:2016-07-21 21:27:39
【问题描述】:
当用户点击标签栏按钮时,我正在尝试创建自定义标签栏动画。
我已经实现了一个实现 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 方法来工作
我在这里错过了什么?
【问题讨论】:
-
你希望它什么时候被调用?
-
用户点击标签栏按钮时不应该调用它吗?
-
我希望它在用户点击标签栏按钮时被调用.. 但它不是
标签: ios objective-c uitabbarcontroller uiviewanimation