gpt4 book ai didi

ios - 想在 IOS 中选择相同的标签栏时调用 myMethod()

转载 作者:行者123 更新时间:2023-11-29 10:37:54 27 4
gpt4 key购买 nike

我想调用我自己的方法,即 myMethod()选择已经选择的同一选项卡栏时。我曾尝试调用 didSelectMethod() 但它没有在我的 ViewController 类中调用。请帮助我,谢谢美洲虎

最佳答案

在你拥有你的tabBarController 实例的地方你设置委托(delegate)

tabBarController.delegate= self; // It is must to set delegate

添加下面的委托(delegate)方法

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if ([viewController respondsToSelector:@selector(myMethod)]) {
[viewController performSelector:@selector(myMethod)];
}
}

关于ios - 想在 IOS 中选择相同的标签栏时调用 myMethod(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26008954/

27 4 0