views:

262

answers:

1

I have a button in a custom UITableViewCell. Its UITableView is controlled by a UIViewController. I would like to return to the RootView when that button is clicked.

I am trying to use [self.superview.navigationController popViewControllerAnimated:YES]; in the target Action of the button, which is in the UITableViewCell.m file. However, it doesn't recognize "navigationController" because it is not in the stack.

How can I return to the RootView when that button is clicked?

+1  A: 

Views have no explicit relation to controllers and views cannot be in the controller stack. Set the button target to be a UIViewController instance and in the action method call:

[self.navigationController popToRootViewControllerAnimated:YES|NO];
drawnonward
Thanks for the answer. Sorry for the strange wording, I'm a noob. I don't understand how to "Set the button target to be a UIViewController instance".
Chi Rod
You have a UIViewController that controls the UITableView and is probably the delegate. When you create the button, set the target to be that UIViewController. If the target is being set in a xib, set it to the controller of the table.
drawnonward
Got it working. Thanks drawnonward! Much appreciated!
Chi Rod