简体   繁体   English

如何从自定义UITableViewCell的按钮单击弹出popViewController

[英]How to popViewController from button click of custom UITableViewCell

I have a button in a custom UITableViewCell. 我在自定义UITableViewCell中有一个按钮。 Its UITableView is controlled by a UIViewController. 其UITableView由UIViewController控制。 I would like to return to the RootView when that button is clicked. 单击该按钮后,我想返回到RootView。

I am trying to use [self.superview.navigationController popViewControllerAnimated:YES]; 我正在尝试使用[self.superview.navigationController popViewControllerAnimated:YES]; in the target Action of the button, which is in the UITableViewCell.m file. 在按钮的目标操作(位于UITableViewCell.m文件中)中。 However, it doesn't recognize "navigationController" because it is not in the stack. 但是,它不能识别“ navigationController”,因为它不在堆栈中。

How can I return to the RootView when that button is clicked? 单击该按钮后如何返回RootView?

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: 将按钮目标设置为UIViewController实例,并在action方法调用中将其设置为:

[self.navigationController popToRootViewControllerAnimated:YES|NO];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM