UISwipeActionsConfiguration-表格行滑

2020-05-21  本文已影响0人  js_huh

是什么?

有什么用?

怎么使用?

示例

- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView
leadingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath{

UIContextualAction * deleteAction =  [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
    ....
   //执行操作
   completionHandler(YES);
 }];

UIContextualAction * signAction =  [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:@"编辑" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
    ....
   //执行操作
   completionHandler(YES);
 }];

NSArray<UIContextualAction *> * arrayTemp = @[deleteAction,signAction];
UISwipeActionsConfiguration * swipeConfiguration = [UISwipeActionsConfiguration configurationWithActions: arrayTemp];
//完全滑动时,是否执行第一个操作
//swipeConfiguration.performsFirstActionWithFullSwipe = YES;
return swipeConfiguration;
}

效果图


完全滑动:多个按钮,因滑动而成为1个按钮。


performsFirstActionWithFullSwipe

performsFirstActionWithFullSwipe 默认或者为Y时的含义是:完全滑动时,自动执行排列在第一个按钮的操作. (如上面示例, 第一个操作,指的是"删除")
performsFirstActionWithFullSwipe 为 NO 时: 就不会出现"完全滑动",这种情况发生.


也可以看看

UIContextualAction - 用户滑动表格行后,执行操作的事件
UIContextualActionStyle - 操作按钮的样式
UIContextualActionHandler - 执行操作的代码块


来自于哪里?

上一篇下一篇

猜你喜欢

热点阅读