iOS 11 editActionsForRowAtIndexPath

iOS 11下 editActionsForRowAtIndexPath被替换成两个新的代理

Demo

// iOS 11 新特性 左边侧滑

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

// iOS 11 新特性 右边侧滑
- (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath {
}

直接进行左右两边进行侧滑操作

UIKIT_EXTERN API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos)
@interface UIContextualAction : NSObject

+ (instancetype)contextualActionWithStyle:(UIContextualActionStyle)style title:(nullable NSString *)title handler:(UIContextualActionHandler)handler;

@property (nonatomic, readonly) UIContextualActionStyle style;
@property (nonatomic, copy, readonly) UIContextualActionHandler handler;

@property (nonatomic, copy, nullable) NSString *title;
@property (nonatomic, copy, nullable) UIColor *backgroundColor; // a default background color is set from the action style
@property (nonatomic, copy, nullable) UIImage *image;
- (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath {
  
    ICCollectionBaseCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (@available(iOS 11.0, *)) {
        UIContextualAction *shareRowAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:@"" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
            [self selectBtnClicked:cell];
            if ([self.delegate respondsToSelector:@selector(didClickForwardBtn:)]) {
                [self.delegate didClickForwardBtn:cell];
            }
            completionHandler(YES);
        }];
        shareRowAction.image = [UIImage imageNamed:@"icon_collection_slide_share"];
        shareRowAction.backgroundColor = BACKGROUNDCOLOR;
        
        UIContextualAction *deleteRowAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
            [self selectBtnClicked:cell];
            if ([self.delegate respondsToSelector:@selector(didClickDeleteBtn:)]) {
                [self.delegate didClickDeleteBtn:cell];
            }
            completionHandler(YES);
        }];
        deleteRowAction.image = [UIImage imageNamed:@"icon_collection_slide_delete"];
        deleteRowAction.backgroundColor = BACKGROUNDCOLOR;
        
        UISwipeActionsConfiguration *config = [UISwipeActionsConfiguration configurationWithActions:@[deleteRowAction, shareRowAction]];
        return config;
    } else {
        // Fallback on earlier versions
    }
    return nil;
}

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏专知

2018年SCI期刊最新影响因子排行,最高244,人工智能TPAMI9.455

2018年6月26日,最新的SCI影响因子正式发布,涵盖1万2千篇期刊。CA-Cancer J Clin 依然拔得头筹,其影响因子今年再创新高,达244.585...

1282
来自专栏CreateAMind

OpenPose: Keypoint Detection And Multi-Threading C++ Library

https://github.com/CMU-Perceptual-Computing-Lab/openpose

4124
来自专栏一个会写诗的程序员的博客

java.base.jmod

/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/jmods$ jmod list java....

1112
来自专栏linux驱动个人学习

高通msm8909耳机调试

1、DTS相应修改: DTS相关代码:kernel/arch/arm/boot/dts/qcom/msm8909-qrd-skuc.dtsi: 1 s...

7605
来自专栏Hadoop数据仓库

Oracle sqlldr 如何导入一个日期列

1. LOAD DATA INFILE * INTO TABLE test FIELDS TERMINATED BY X'9' TRAILING NULLCO...

1806
来自专栏MelonTeam专栏

Bitmap 源码阅读笔记

导语: Android 系统上的图片的处理,跟Bitmap 这个类脱不了关系,我们有必要去深入阅读里面的源码,以便在工作中能更好的处理Bitmap相关的问题...

2518
来自专栏WOLFRAM

向日葵中的数学之美

1843
来自专栏我和未来有约会

简练的视图模型 ViewModel

patterns & practices Developer Center 发布了 Unity Application Block 1.2 for Silver...

2199
来自专栏搞前端的李蚊子

Html5模拟通讯录人员排序(sen.js)

// JavaScript Document  var PY_Json_Str = ""; var PY_Str_1 = ""; var PY_Str_...

5976
来自专栏增长技术

App Guide相关

##TourGuide https://github.com/worker8/TourGuide

702

扫码关注云+社区