Calling a method in another viewController
I have a UINavigationController containing a UIViewController with an MKMapView onto which I push a UITableViewController which contains a list of items obtained from Core Data. Based on the selected item on the table, I want to return to the navigation controller and call a method, passing the object selected in the table. How can I achiev开发者_开发技巧e this?
You don't actually "return" to a UINavigationController. That is to say, it has no UIView associated with it. It is intended to be treated as a way to just keep track of a stack of UIViewControllers. Since it sounds like this UITableViewController is your root view, there isn't anywhere to "return" back to. I suggest you simply push another UIViewController in the selectRow: handler that will be able to bring up the view detailing the selected text field.
You can make your first UIViewController a delegate of your UITableViewController, and invoke appropriate methods when an object is selected in the table. Something like this:
if (delegate && [delegate respondsToSelector:@selector(tableView:didSelectObject:)]) {
[delegate tableView:self didSelectObject:object];
}
精彩评论