[英]Transition Delegate for UITabBarController animation
我已经创建了一个自定义的UIViewControllerAnimationTransition
类,并且需要在切换选项卡时使其为UITabBarController
设置动画。
但是, tabBarController
不使用常规选项卡栏。 我有一个类似于它的自定义实现,当按下按钮时,它会调用以下代码:
tabBarController.selectedIndex = index
目前我有tabBarController
(子类)作为其自己的transitionDelegate
的委托。 但是,委托方法animationControllerForPresentedController
实际上从未被调用过。
标签栏控制器是否可以成为自己的委托? 如果是这样,为什么转换代码永远不会被调用?
animationControllerForPresentedController
是标签栏控制器的错误方法。
在UITabBarController子类中,采用UITabBarControllerDelegate
协议并将其设置为自己的delegate
。 然后,使用tabBarController: animationControllerForTransitionFromViewController: toViewController:
返回自定义UIViewControllerAnimatedTransitioning
对象。
为了获得更好的可视化,看看VCTransitionsLibrary在TabBarDemo文件夹中。
您是否使用过这样的委托方法?
@interface BTSlideInteractor : NSObject <UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate>
- (IBAction)showModalButtonWasTouched:(id)sender
{
BTSlideInteractor *interactor = [[BTSlideInteractor alloc] init];
interactor.presenting = YES;
BTModalViewController *modalController = [self.storyboard instantiateViewControllerWithIdentifier:@"ModalViewController"];
modalController.modalPresentationStyle = UIModalPresentationCustom;
modalController.transitioningDelegate = interactor;
[self presentViewController:modalController animated:YES completion:nil];
}
使用此链接参考: https : //github.com/brightec/CustomViewControllerTransition/blob/master/test/BTViewController.m
如果您没有找到解决方案,请添加您的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.