取消选择或取消选择iOS 5中标签栏中的所有标签 [英] Deselect or unselect all tabs in tabbar in iOS 5

查看:188
本文介绍了取消选择或取消选择iOS 5中标签栏中的所有标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS开发的新手,我已经开始直接使用IOS 5了。我创建了一个故事板,其中包含一个tabview控制器作为其rootviewcontroller。我已经添加了2个标签。

I am new to iOS development and I have started with IOS 5 directly. I have created a storyboard which consists of a tabview controller as its rootviewcontroller. I have put 2 tabs to it.

我想取消选择/取消选择最初的所有标签。我该怎么做呢?我试过以下

I want to deselect/unselect all the tabs initially. How do I do this? I have tried the following

 UIView *view = [[UIView alloc]initWithNibName:@"view" bundle:[NSBundle mainBundle]];
    [self.tabBarController setSelectedViewController:nil];
    [self.tabBarController setSelectedViewController:view];

我添加了一个带有标识符view的视图。

where I have added a view with identifier "view".

但这不起作用,它给出了错误:

But this didn't work, it gives error:

 unrecognized selector sent to instance

我还尝试了以下

[self.tabBarController.tabBar setSelectedItem:nil];

但它说


'NSInternalInconsistencyException',原因:'不允许直接修改由标签栏控制器管理的标签栏。'

'NSInternalInconsistencyException', reason: 'Directly modifying a tab bar managed by a tab bar controller is not allowed.'

我已在第一个选项卡的控制器中尝试了此代码。我想这样做是因为我想在第一个标签视图的顶部放置一个默认视图,并在下面任何一个标签上点击使用后隐藏它。

I have tried this code in controller for the first tab. I want to do this because I want to put a default view on top of first tab view and hide it once the use is clicked on any of the tabs below.

推荐答案

我用它来清除任何选中的tabBarItems

I use this to clear any selected tabBarItems

[myTabBar setSelectedItem:nil];

这篇关于取消选择或取消选择iOS 5中标签栏中的所有标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆