开发者

Present Navigation Table View modally, who is the delegate?

开发者 https://www.devze.com 2022-12-10 07:18 出处:网络
Basically I have a hierarchy of locations: country, state/prov, city. I want to present an \"Add Location\" modal table using a delegate.

Basically I have a hierarchy of locations: country, state/prov, city.

I want to present an "Add Location" modal table using a delegate.

I realize the best way to do this is to present my top level elements in a TableView, and if they are selected, I want to go down to the 'next' level. Any of the locations however, on any level should be able to be 'added' so I'm either going to have an accessory button, or just a custom button that says add on the cell.

I want to do this using delegates but I'm not quite sure where the delegate should be. I can think of 2 options:

1. Subclass UINavigationController to a LocationNavigationController with a LocationNavigationControllerDelegate but then I need to find someway to message back down with my LocationListTableView

2. Make a Location开发者_JS百科ListTableView that holds a delegate, and everytime I go to the 'next' level down, just keep passing the delegate along. So when they finally hit the 'add' button the cell, my original ViewController can get the location and dismiss it. It does seem wrong though passing the Delegate all the way up the chain of TableViews. In this method I would just create a new NavController first, then pop on the root tree of the LocationListTableView


Have a look at the View Controller Programing Guide, specifically, the section on dismissing a modal controller.

Their code example is using a modal screen to add a recipe to a table view controller which presented it.

0

精彩评论

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