问题
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