SWTableViewCell的RightUtilityButton当我点击表格单元格时如何直接显示

时间:2014-07-27 03:18:48

标签: ios objective-c

https://github.com/CEWendel/SWTableViewCell

我希望当我点击(而不是拖动)表格单元格时,SWTableViewCell的RightUtilityButton会直接显示。

SWTableViewCell似乎没有提供此接口

1 个答案:

答案 0 :(得分:2)

调用showRightUtilityButtonsAnimated:方法。我正在使用示例代码.Replace didSelectRowAtIndexPath并将UMTableViewCell更改为YourCellClassName

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"cell selected at index path %ld:%ld", (long)indexPath.section, (long)indexPath.row);
    NSLog(@"selected cell index path is %@", [self.tableView indexPathForSelectedRow]);


    if (!tableView.isEditing) {
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }

    //if you want to hide other cell which are opened first
    for (UMTableViewCell *cell in [tableView visibleCells]) {

        [cell hideUtilityButtonsAnimated:YES];
    }

    UMTableViewCell *cell = (UMTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
    [cell showRightUtilityButtonsAnimated:YES];


}