How popViewController from button click of custom UITableViewCell

I have a button in a custom UITableViewCell. Its UITableView is controlled by a UIViewController. I would like to return to RootView when this 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 does not recognize "navigationController" because it is not on the stack.

How can I go back to RootView when this button is clicked?

+2


a source to share


1 answer


Views are not explicitly related to controllers, and views cannot be on the controller stack. Set the target of the button as an instance of UIViewController and in the call to the action method:



[self.navigationController popToRootViewControllerAnimated:YES|NO];

      

+5


a source







All Articles