美文网首页
iOS8下左滑出多个按钮

iOS8下左滑出多个按钮

作者: 未来可期me | 来源:发表于2016-10-27 17:24 被阅读34次
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //删除按钮
    UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath){
        [_dataArray removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationAutomatic];
    }];
     
 
    //置顶按钮
    UITableViewRowAction *toTopRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath){
         
        NSLog(@"置顶");
         
    }];
    toTopRowAction.backgroundColor = [UIColor orangeColor];
     
    //其他按钮
    UITableViewRowAction *otherRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"其他" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath){
        NSLog(@"其他");
    }];
 
    otherRowAction.backgroundColor = [UIColor lightGrayColor];
 
    //返回按钮数组
    return @[deleteRowAction, toTopRowAction, otherRowAction];
}

相关文章

网友评论

      本文标题:iOS8下左滑出多个按钮

      本文链接:https://www.haomeiwen.com/subject/sclsuttx.html