我有一个自定义后退按钮:
let backButton = UIBarButtonItem(title: "<", style: UIBarButtonItemStyle.Plain, target: self, action: "goBack")
其中调用:
func goBack() {
self.navigationController?.popToRootViewControllerAnimated(true)
}
这有效,但非常笨拙。我不想制作一个已经是导航控制器的方法。为什么我不能只制作发件人导航控制器并将操作设置为 popToRootViewControllerAnimated(true)
let backButton = UIBarButtonItem(title: "<", style: UIBarButtonItemStyle.Plain, target: navigationController!, action: "popToRootViewControllerAnimated(true)")
是的,您可以通过以下更改来做到这一点。
action: "popToRootViewControllerAnimated:"