用于UITabBarControlleranimation的转换委托
我已经创build了一个自定义的UIViewControllerAnimationTransition
类,并且在切换选项卡时需要使UITabBarController
animation效果。
但tabBarController
不使用常规标签栏。 我有一个自定义的实现,就像这样,当一个button被按下时,它会调用这个代码:
tabBarController.selectedIndex = index
目前我有tabBarController
(子类)作为它自己的transitionDelegate
的委托。 虽然委托方法animationControllerForPresentedController
从来没有被实际调用过。
标签栏控制器是自己的委托是好的吗? 如果是这样,为什么转换代码从来没有真正被调用?
animationControllerForPresentedController
是标签栏控制器的错误方法。
在UITabBarController子类中,采用UITabBarControllerDelegate
协议并将其设置为其自己的delegate
。 然后,使用tabBarController: animationControllerForTransitionFromViewController: toViewController:
返回自定义的UIViewControllerAnimatedTransitioning
对象。
为了获得更好的可视化,请查看TabBarDemo文件夹中的VCTransitionsLibrary。
你是否使用这样的代表方法?
@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
如果您没有find解决方法,请添加您的代码。