gpt4 book ai didi

iOS/Objective c - UITabBarControllerDelegate - 未调用自定义选项卡动画委托(delegate)

转载 作者:行者123 更新时间:2023-11-28 19:36:18 25 4
gpt4 key购买 nike

我正在尝试在用户点击标签栏按钮时创建自定义标签栏动画。

我已经实现了一个实现了 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;
}

出于某种原因,负责转换的委托(delegate)方法未被调用。我读过 docs并且看不出有任何理由不叫他们。

我已经正确设置了我的委托(delegate)并确认它是通过实现 shouldSelectViewController 方法来工作

我在这里错过了什么?

最佳答案

我认为您对要完成的任务使用了错误的委托(delegate)方法。尝试使用:

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

这将在用户点击不同的选项卡时调用。

关于iOS/Objective c - UITabBarControllerDelegate - 未调用自定义选项卡动画委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38514657/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com