开发者

How to retain indexPath value through multiple detail view controllers?

How can I retain the indexPath value from my RootViewControl开发者_如何学运维ler through my multiple detail view controllers?

I have a split view controller and multiple detail views with a toolbar.

I want to be able to change the detailview upon calling a method which retrieves the indexPath.row value and uses indexPath.row+1.

So basically, I want each view controller to have a selectedRow = indexPath assignment. Currently I am getting an indexPath not declared for use error.


There are lots of ways to manage this.

Every time the selection changes, each of the detail view controllers can write their selection state to some common location. Whenever on gets a viewWillAppear: it sets its selection.

or

If you're using a segmented view controller, in the action it is invoking, it can take the selection from the current detail view controller, change the controllers, and set the selection in the new controller.

or … ad infinitum


Familiarize yourself with the documentation of UITableViewController - indexPathForSelectedRow is how you'll grab the selected index, and selectRowAtIndexPath:animated:scrollPosition: is how you set it on a table. Be warned that sending an invalid indexPath will cause an exception. If the tables are not the same size this could be a problem. wrap with a @try or check before calling

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜