美文网首页
cell的多个侧滑按钮

cell的多个侧滑按钮

作者: 奔波儿灞与灞波儿奔 | 来源:发表于2016-09-27 15:29 被阅读73次

-(NSArray*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{

UITableViewRowAction *action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"增加" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

NSLog(@"%@", indexPath);

}];

action.backgroundColor = [UIColor redColor];

UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"减少" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

NSLog(@"%@", indexPath);

}];

action2.backgroundColor = [UIColor greenColor];

UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

NSLog(@"%@", indexPath);

}];

action3.backgroundColor = [UIColor blueColor];

UITableViewRowAction *action4 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"哈哈" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

NSLog(@"%@", indexPath);

}];

action4.backgroundColor = [UIColor blackColor];

return @[action,action2,action3,action4];

}

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

{

[tableView reloadData];

//[tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];

}

//系统按钮方法

// [self.tableView setEditing:YES];

相关文章

网友评论

      本文标题:cell的多个侧滑按钮

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