iOS

当前位置:首页 > iOS

ios – TabBarController返回null - iOS

我在故事板中有一个tabbarcontroller作为初始视图控制器 这是如何返回null的 UITabBarController* tabbarController = (UITabBarController*) self...
我在故事板中有一个tabbarcontroller作为初始视图控制器

这是如何返回null的

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

本来就是我想要做的

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

为什么我会变空?

解决方法

返回null的原因是self是你的UITabBarController,因此,它在self.tabBarController上没有任何东西

您的代码应如下所示:

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

以上是来客网为你收集整理的ios – TabBarController返回null全部内容,希望文章能够帮你解决ios – TabBarController返回null所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。

相关内容

文章评论

表情

共 0 条评论,查看全部
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~

评论排行榜

热门标签