我已经从https://github.com/CEWendel/SWTableViewCell
实现了SWTableView类它工作正常,但我不知道如何在单击显示的按钮时检索单元格对象的值。
这是我如何在cellForRowAtIndexPath方法中获取对象值:
NSString *date = [self stringValueOfDictionaryObject:(id)[[historialServicios objectAtIndex:indexPath.row] valueForKey:@"date"]];
我添加了三个按钮,当用户滑动单元格时会显示这些按钮。 我需要的是添加必须获取所选行对象的值的按钮操作。主要是,我需要在点击“更多”按钮时检索字符串日期
这是didTriggerRightUtilityButtonWithIndex方法。
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index {
switch (index) {
case 0:
{
// More button is pressed
UIActionSheet *shareActionSheet = [[UIActionSheet alloc] initWithTitle:@"Share" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Share on Facebook", @"Share on Twitter", nil];
[shareActionSheet showInView:self.view];
[cell hideUtilityButtonsAnimated:YES];
break;
}
case 1:
{
// Other button is pressed
UIActionSheet *shareActionSheet = [[UIActionSheet alloc] initWithTitle:@"Share" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Share on Facebook", @"Share on Twitter", nil];
[shareActionSheet showInView:self.view];
[cell hideUtilityButtonsAnimated:YES];
break;
}
case 2:
{
// Delete button is pressed
NSIndexPath *cellIndexPath = [self.tableView indexPathForCell:cell];
[self.tableView deleteRowsAtIndexPaths:@[cellIndexPath] withRowAnimation:UITableViewRowAnimationLeft];
break;
}
default:
break;
}
}
答案 0 :(得分:0)
我已按如下方式解决了这个问题:
NSLog(@"INDEXPATH=%@",[self stringValueOfDictionaryObject:(id)[[historialServicios objectAtIndex:cellIndexPath.row]
现在我可以从所选行中检索任何对象值...