Я хотел бы подражать удалению, чтобы удалить функцию UITableViewCell так же, как почтовое приложение в iOS 8. Я не имею в виду прокрутку, чтобы открыть кнопку удаления. Я имею в виду, когда вы саботируете, он обесценивает 3 действия, но если вы продолжаете прокручивать влево, электронное письмо удаляется.
В iOS 8 UITableView имеет новый метод, в котором вы можете предоставить данные для отображения любого количества кнопок:
#ifdef __IPHONE_8_0
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewRowAction *viewStackRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Stack" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
SM_LOG_DEBUG(@"View Stack Action");
}];
viewStackRowAction.backgroundColor = [UIColor radiusBlueColor];
UITableViewRowAction *viewUserRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"User" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
SM_LOG_DEBUG(@"View User Action");
}];
viewUserRowAction.backgroundColor = [UIColor radiusLightBlueColor];
UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
SM_LOG_DEBUG(@"Delete");
}];
deleteRowAction.backgroundColor = [UIColor redColor];
return @[deleteRowAction, viewUserRowAction, viewStackRowAction];
}
#endif
Я не вижу никакого API для обнаружения, если вы продолжаете прокручивать. Я сделал grepped для 8_0 в UITableView.h, и описанный выше метод кажется единственным новым.
Я предполагаю, что можно контролировать смещение вида прокрутки или добавить/захватить UIPanGestureRecognizer. Я просто хотел убедиться, что использую метод по умолчанию, если он есть (и получить анимацию для "бесплатно" )