Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何使表格视图单元格作为按钮工作?_Iphone_Objective C_Ios_Xcode - Fatal编程技术网

Iphone 如何使表格视图单元格作为按钮工作?

Iphone 如何使表格视图单元格作为按钮工作?,iphone,objective-c,ios,xcode,Iphone,Objective C,Ios,Xcode,我正在尝试制作一个应用程序,用户将按下一个单元格,该单元格将用作按钮,现在我如何使该单元格用作按钮并执行操作,或者如何知道按下的是哪个单元格?阅读苹果的文档 您将发现tableView:didDeceloseRowatineIndexPath:请阅读文档,但基本上,当您设置tableviewcontroller的委托时,它会在单击时调用此方法: -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath

我正在尝试制作一个应用程序,用户将按下一个单元格,该单元格将用作按钮,现在我如何使该单元格用作按钮并执行操作,或者如何知道按下的是哪个单元格?

阅读苹果的文档

您将发现
tableView:didDeceloseRowatineIndexPath:

请阅读文档,但基本上,当您设置tableviewcontroller的委托时,它会在单击时调用此方法:

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath

indexpath保存节和行。如果只使用一个节,则
indexPath.row
将返回所单击单元格的索引。

您将实现该方法

只要用户点击任何单元格,就会调用该方法。如果传递的
indepath
是按钮单元格的索引路径,那么您可以执行任何应该执行的操作

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
当用户点击单元格时,调用此方法<代码>索引XPath.section和
索引XPath.row
是您的单元格节和行索引。
如果我正确理解了您的问题,您只需在用户触摸单元格时运行一些代码即可

UITableViewDelegate有一个名为
tableView:didSelectRowatineXpath:
()

只要实现这一点,你就可以在那里做你想做的事情