当单元格中的按钮为clicked.Like时,我需要从每个单元格中获取选择器的值。如果我在黑天鹅单元格中单击snooze按钮,我应该在该单元格中获取选择器的值。我从以下位置获取行详细信息
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int section = indexPath.section;
int row = indexPath.row;
NSLog(@"section: %d / row: %d", section, row); 任何帮助都是非常感谢的。所有单元格都是自定义单元格。

发布于 2015-04-20 20:39:39
您可以从didSelectRowAtIndexPath中每个单元格的选择器中获取值对标记进行签名,如下所示
pickerView.tag=indexPath.row;然后,在选择器委托中,您可以执行如下操作
if (pickerView.tag == 1){
//do stuff
}else (pickerView.tag == 2){
//do other stuff
}如果你也想在这里使用,你也可以使用Switch。
发布于 2015-04-20 20:47:27
你可以使用indexpath.row来setTag到你的UIButtons,如果它是多段的,那么你可以根据它设置你的逻辑,用静态标签设置你的UIPickerView,它永远不应该等于按钮标签,就像Pickerview的999999标签一样。
可以通过addTarget:action:forControlEvent方法设置目标,以调用UIButton的实例方法,如下所示:
//You can set it in `cellForRowAtIndexPath` method
[yourSnoozbuton addTarget:self action:@selector(selectPickerTime:) forControlEvents:UIControlEventTouchDown];在实例方法中,您可以获得如下选择器值,
-(IBAction)selectPickerTime:(UIButton *)sender {
NSIndexPath *nowIndex = [NSIndexPath indexPathForRow:sender.tag inSection:0];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:nowIndex];
UIPickerView *pickerview = [cell viewWithTag:999999];
NSString *str = [timeArray objectAtIndex:[pickerview selectedRowInComponent:0]];
//if multi sectioned, get button as per logic.
}https://stackoverflow.com/questions/29747838
复制相似问题