gpt4 book ai didi

ios - 在委托(delegate)方法中检查所需的 View Controller tabBarController shouldSelectViewController :

转载 作者:行者123 更新时间:2023-11-28 18:21:14 24 4
gpt4 key购买 nike

我在 UITabBarController 中有 3 个 TabBarItems:

<UINavigationController: 0xc76a680>
<SplitViewController: 0xc76a170>
<UINavigationController: 0xca5e6f0>

我在 AppDelegate 中有方法:

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
NSLog(@"tab selected index %@",viewController);
if (viewController == nil ) // I NEED TO IMPLEMENT A CHECk HERE
{
//show popup

return NO; //does not change the tab
}

return YES; //does change the tab
}

那么如何检查应该选择的 View Controller 是第二个导航 Controller 呢?谢谢

最佳答案

试试这段代码

 - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
BOOL result;

if (viewController == [self.tabBarController.viewControllers objectAtIndex:2]) //assuming the index of uinavigationcontroller is 2
{
NSLog(@"Write your code based on condition");
result = NO;
}
else {
result = YES;
}

return result;
}

关于ios - 在委托(delegate)方法中检查所需的 View Controller tabBarController shouldSelectViewController :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20345202/

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