EditActionsForRowAtIndexPath未被调用

时间:2016-06-29 11:37:34

标签: objective-c

我想在tableView单元格滑动中制作2个按钮,然后重写该方法 editactionsforrowatindexpath

简单不行。使用iOS 9。

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}


-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{

}



-(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewRowAction *button = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
                                    {
                                        // Logic
                                    }];
    button.backgroundColor = [UIColor redColor]; //arbitrary color

    UITableViewRowAction *button2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Send SMS " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
                                     {
                                         // Logic
                                     }];
    button2.backgroundColor = [UIColor lightGrayColor];
    return @[button, button2];
}

1 个答案:

答案 0 :(得分:-1)

发现问题,

问题是DataSource Delegate和TableViewDelegate处于2个不同的类