为 UIBarButtonItem 的 rightBarButtonItem 调用的委托方法
点击 UIBarButtonItem 的 rightBarButtonItem 时调用的委托方法是什么?我想在那里实施一项具体行动。
What is the delegate method called when rightBarButtonItem of UIBarButtonItem is tapped? I want to implement a specific action there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有预定义的委托方法。您需要设置委托/操作(类似于 UIControl)。例如,按以下方式在 viewDidLoad 中创建 UIBarButtonItem:
并在视图控制器中实现 actionForTap: 。如果您已经有了 UIBarButtonItem,您可以将目标/操作设置为您想要的委托方法的目标/操作,例如:
作为第三种方法,您可以在 IB 中配置它(但我不会去那里)。
There is no predefined delegate method. You need to set the delegate/action (similar to a UIControl). For example, create the UIBarButtonItem in viewDidLoad the following way:
and implement actionForTap: in your view controller. If you already have the UIBarButtonItem you can set the target/action to those of your desired delegate method, e.g.:
As a third way, you can configure it in IB (but I'm not going there).
您不需要任何委托方法。您可以简单地使用下面的代码。
这是简单地在右侧添加一个按钮并向该按钮添加一个操作的代码。
就我而言,我调用了名为“AddButtonMethod”的方法。
You don't need any delegate method. You can simply use the below code.
This is code for simply adding a button on the right and adding an action to that button.
In my case I called the method named "AddButtonMethod".