воскресенье, 18 августа 2013 г.

UITableViewCell, show delete button on swipe

В таблице UITableView есть такая штука, когда проводишь пальцем по строке, то появляется кнопка удалить. Как сделать чтобы эта кнопка появлялась или не появлялась и как обрабатывать нажатие на кнопку удалить.

// Override to support conditional editing of the table view.
// This only needs to be implemented if you are going to be returning NO
// for some items. By default, all items are editable.
- (BOOL)tableView:(UITableView *)tableView 
  canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return YES if you want the specified item to be editable.
    return YES;
}
 
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView 
  commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
  forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        //add code here for when you hit delete
    }    
}

Комментариев нет:

Отправить комментарий