[英]Perform code when unwind segue with back button
我想在segue返回一步时执行一些代码。 例如,当后退按钮被选中时,我想执行一些代码。
我无法从后退按钮创建新的展开动作,因为故事板中没有后退按钮。 有没有办法插入代码,只要选择后退按钮?
如果你想坚持使用默认的后退按钮,一种方法是子类化导航控制器,并覆盖popViewControllerAnimated:当你点击后退按钮时调用它。
-(UIViewController *)popViewControllerAnimated:(BOOL)animated {
UIViewController *vcToBePopped =[super popViewControllerAnimated:animated];
id vc = self.viewControllers.lastObject; // this will be the controller you're going back to
if ([vc isKindOfClass:IntendedViewController class]) { // replace IntendedViewController with the actual class name you care about
[(IntendedViewController *)vc someMethod];
}
return vcToBePopped;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.