action:@selector(showAlert :)如何在这个showAlert方法中传递参数? [英] action:@selector(showAlert:) how to pass parameter in this showAlert method?

查看:273
本文介绍了action:@selector(showAlert :)如何在这个showAlert方法中传递参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的 UITableViewCell 添加自定义按钮。在该按钮的操作中,我想调用 showAlert:函数,并希望在方法中传递单元格标签。

I am adding custom button to my UITableViewCell. In the action of that button I want to call showAlert: function and want to pass cell label in the method.

如何在此 showAlert 方法中传递参数: action:@selector(showAlert :)

How can I pass a parameter in this showAlert method: action:@selector(showAlert:)?

推荐答案

这是不可能的。你必须创建一个符合IBAction的方法

That's not possible. You have to create a method conforming to IBAction

- (IBAction)buttonXYClicked:(id)sender;

在此方法中,您可以创建并调用UIAlertView。不要忘记将按钮与Interface Builder中的方法连接。

In this method you can create and call the UIAlertView. Don't forget to connect the button with the method in Interface Builder.

如果您想区分多个按钮(例如,每个表格单元格中有一个),您可以设置按钮的tag属性。然后检查sender.tag,从哪个按钮点击。

If you like to distinguish between multiple Buttons (e.g. you have one in each table cell) you can set the tag property of the button. And then check sender.tag from which button the click comes.

这篇关于action:@selector(showAlert :)如何在这个showAlert方法中传递参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆