Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.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 自定义UITableViewCell项问题_Iphone_Cocoa Touch_Uitableview_Action_Textfield - Fatal编程技术网

Iphone 自定义UITableViewCell项问题

Iphone 自定义UITableViewCell项问题,iphone,cocoa-touch,uitableview,action,textfield,Iphone,Cocoa Touch,Uitableview,Action,Textfield,我是个新手 我有一个自定义UITableViewCell,其中包含3项: 标签 超文本字段 还有一个按钮 我的问题是,我如何知道按钮是从哪个单元格单击的,文本字段是从哪个单元格编辑的 有办法追踪他们吗 感谢您的回复。我通常会在配置自定义单元格后,将单元格的NSIndexPath保存在状态UIControlStateApplication按钮的标题中 在tableView:cellForRowAtIndexPath:method中,配置单元格时: [theButton setTitle:(NSSt

我是个新手

我有一个自定义UITableViewCell,其中包含3项:

标签 超文本字段 还有一个按钮

我的问题是,我如何知道按钮是从哪个单元格单击的,文本字段是从哪个单元格编辑的

有办法追踪他们吗


感谢您的回复。

我通常会在配置自定义单元格后,将单元格的NSIndexPath保存在状态UIControlStateApplication按钮的标题中

在tableView:cellForRowAtIndexPath:method中,配置单元格时:

[theButton setTitle:(NSString *)indexPath forState:UIControlStateApplication];
然后,在按钮操作中:


- (IBAction) buttonWasClicked:(UIButton *) senderButton {
    NSIndexPath *indexPath;

    indexPath = (NSIndexPath *)[senderButton titleForState:UIControlStateApplication];

    NSLog(@"Sender button was clicked in cell at NSIndexPath section: %d row: %d ", [indexPath section], [indexPath row]);
}

我对这种方式不是很满意。如果有人有更干净的方法,我很想听听。

如果你只有一个部分,你可以将
indexPath.row
存储在
按钮中。标记
并在该按钮触发的操作中检索它