0

奇怪的行为:

Cell 在第一次启动时重新加载其操作,但trailingSwipeActionsConfigurationForRowAtIndexPath只调用一次,有什么想法吗?

编码:

- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {

UIContextualAction *deleteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:nil handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {

   //...

}];

UIContextualAction *moreAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:@"" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {

    //...

    completionHandler(YES);
}];

deleteAction.backgroundColor = [UIColor colorWithRed:(245/255.0) green:(78/255.0) blue:(70/255.0) alpha:1];
moreAction.backgroundColor = [UIColor colorNamed:@"CL_LightGray_2"];

UISwipeActionsConfiguration *SwipeActions = [UISwipeActionsConfiguration configurationWithActions:@[deleteAction,moreAction]];
SwipeActions.performsFirstActionWithFullSwipe=false;
return SwipeActions;

}

4

1 回答 1

0

我发现了问题!对于所有将来遇到同样问题的人:

    [UIView animateWithDuration:1.0 animations:^{

    //...

  }];

一旦此代码在其他地方执行,单元格的操作也会重新加载。这会产生奇怪的行为。

于 2018-08-02T12:30:20.770 回答