如何更改选项卡栏的选定索引
在我的应用程序中有一个选项卡栏。在选项卡栏的某个元素(例如选项卡栏索引 1 处的元素)上有一些按钮,单击它们将引导至选项卡栏的其他元素(例如选项卡栏索引 3 处的元素)下的某些页面。
我能够导航到所需的页面,但选项卡栏选择未正确显示。即使页面位于第三个选项卡栏元素中,也会选择第一个元素。
怎么解决这个问题呢?想法请
In my app there is a tab bar. On one of the elements of the tabbar (say element at index 1 of the tabbar) there are some buttons on clicking them will guide to some pages which are under some other element of the tabbar(say element at index 3 of the tabbar).
I was able to navigate to the required page but the tabbar selection is not properly displayed. Even though the page is in 3rd tab bar element, the 1st element is selected.
How to solve this? Ideas plz
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后我得到了解决方案。
在回答这个问题之前,让我告诉你一件事,我认为所有问题的发生都是因为选项卡栏是通过代码实现的。如果是通过 nib 完成的话,问题就不会出现。
我通过以下方式解决了这个问题:
我没有使用 self.navigationcontoller 推送所需的视图控制器的对象,而是对选项卡栏的所需视图进行了类型转换。
还请检查代码
Finally I got the solution.
Before going into the answer let me tell u one thing, i think all the problem occured because the tab bar was implemeented via code. If it was done through nib then the problem won't come .
I solved this problem in the following manner:
Instead of pushing the required view controller's object using self.navigationcontoller i typecasted the tabbar's required view.
Please check the code also