Activate Tab in UITabbarcontroller from other screen

假装没事ソ 提交于 2019-12-25 01:26:12

问题


I am developing an App with content that is crosslinked to other content.

The App contains 5 Tabs. Each Tab has it's Tableviews and detailsviews. From the detailview of a Tab, one can proceed to other items from another tab.

For Example: Tab 1 > TableView List Categories > TableView List Items > DetailView > TableView crosslinked Items > Tab 2 > DetailView

(Hope that makes any sense! :D)

When I activate the Tab 2 by tabbarController.selectedIndex = 1; it doesn't open the requested detailview but the TableView List Categories.

Is there a way of doing this?

Thanks!!


回答1:


If DetailView is pushed by willSelectRowAtIndexPath or didSelectRowAtIndexPath of your UITableViewDelegate, than you need not only switch tab, but issue above mentioned call directly or call selectRowAtIndexPath of your UITableView (latter is better).

Correction!!!

I was not right above!!!! selectRowAtIndexPath doesn't cause the delegate to receive a tableView:willSelectRowAtIndexPath: or tableView:didSelectRowAtIndexPath: message. What to do? add new method pushDetailViewController into your TableViewController. Than in didSelectRowAtIndexPath easy call this new method. And now in method where your switch tab next call this method pushDetailViewController. That's all.



来源:https://stackoverflow.com/questions/7496356/activate-tab-in-uitabbarcontroller-from-other-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!