gpt4 book ai didi

ios - TabBarController 返回 null

转载 作者:可可西里 更新时间:2023-11-01 03:45:27 26 4
gpt4 key购买 nike

我在 Storyboard中有一个 tabbarcontroller 作为初始 View Controller

enter image description here

enter image description here

这怎么返回null

UITabBarController* tabbarController = (UITabBarController*) self.tabBarController;
NSLog(@"%@",tabbarController);
NSLog(@"%@",self.navigationController.tabBarController);

本来我想做的事情

NSMutableArray *newTabs = [NSMutableArray arrayWithArray:[self.tabBarController viewControllers]];
NSLog(@"\n\n\n%lu\n\n\n",(unsigned long)[newTabs count]);
NSLog(@"self.tabBarController.viewControllers %@ \n\n",self.tabBarController);
[newTabs removeObjectAtIndex: 1];
[self.tabBarController setViewControllers:newTabs];

为什么我得到的是空值?

最佳答案

返回 null 的原因是 self 是您的 UITabBarController,因此,它在 self.tabBarController 上没有任何内容/p>

您的代码应如下所示:

NSMutableArray *newTabs = [NSMutableArray arrayWithArray:[self viewControllers]];
NSLog(@"\n\n\n%lu\n\n\n",(unsigned long)[newTabs count]);
NSLog(@"self.viewControllers %@ \n\n",self);
[newTabs removeObjectAtIndex: 1];
[self setViewControllers:newTabs];

关于ios - TabBarController 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33088575/

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