gpt4 book ai didi

ios - 使用导航 Controller 作为发送者

转载 作者:行者123 更新时间:2023-11-29 02:22:15 26 4
gpt4 key购买 nike

我有一个自定义后退按钮:

let backButton = UIBarButtonItem(title: "<", style: UIBarButtonItemStyle.Plain, target: self, action: "goBack")

调用:

func goBack() {
self.navigationController?.popToRootViewControllerAnimated(true)
}

这可行,但它很笨拙。我不想制作一个已经是导航 Controller 方法的方法。为什么我不能只创建发送者 navigationController 并将操作设置为 popToRootViewControllerAnimated(true)

let backButton = UIBarButtonItem(title: "<", style: UIBarButtonItemStyle.Plain, target: navigationController!, action: "popToRootViewControllerAnimated(true)")

最佳答案

是的,您可以通过以下更改来做到这一点。

action: "popToRootViewControllerAnimated:"

关于ios - 使用导航 Controller 作为发送者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28006933/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com