Показать несколько данных, после пролистывания в ячейке таблицы - PullRequest
0 голосов
/ 21 ноября 2018

У меня есть табличное представление с некоторыми данными.В то время как на левой ячейке я хочу «Удалить» и «Редактировать».Я получил «Удалить» с помощью приведенного ниже кода.Пожалуйста, помогите мне решить эту проблему ..

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        return NO;

    }
    return YES;
}

  - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [self.circleGroupArray removeObjectAtIndex:indexPath.row];

        [_myCircleTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }
}

1 Ответ

0 голосов
/ 21 ноября 2018

Используйте этот метод в своем классе. Если вам нужно больше действий, вы можете создать больше UITableViewRowActions и добавить их в массив.

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

   UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Clona" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
      //add edit action here
   }];
   editAction.backgroundColor = [UIColor blueColor];

   UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Delete"  handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
      //add delete action here
   }];
   deleteAction.backgroundColor = [UIColor redColor];
   return @[deleteAction,editAction];
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...