zoukankan      html  css  js  c++  java
  • UITableViewCell 左侧滑动删除按钮 添加图片 (不完美解决)

    *需求:给cell左侧滑动删除按钮添加图片

    //目前的解决方法

    链接: https://pan.baidu.com/s/1kVE5gMF 密码: zaph

    *装态:还在解决

    网上查过资料一直没好的解决思路!

    一、按照一般思路,在delegate方法(如下)中进行更改。

    - (nullable NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{

      

      UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删1除"     handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
      NSLog(@"点击了删除");
      }];
      UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"编1辑"       handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
      NSLog(@"点击了编辑");
      }];
      editAction.backgroundColor = [UIColor grayColor];
      return @[deleteAction, editAction];

    }

    ****1一般方法****

    1.1

      UITableViewRowAction :删除按钮的类!对其自定义子类,对子类添加方法,实现效果。

    1.2 

      UITableViewRowAction:NSObject  (继承NSobject) ,这个类直接继承根类,类中方法也没有添加img方法。目前认为行不通!(网上资料也没有找到类似解决方法)

    ****** 不完美解决(大致实现功能需求) ********

    一、思路

    1.自定义一个cell   @interface MyTabViewCell : UITableViewCell   

    2.在layoutSubviews方法中遍历出删除按钮对象 (类型是:UITableViewCellDeleteConfirmationView)!可以直接看为UIButton对象。对button对象的操作(img,titile)比较容易。有图有真相

     实现的效果

    二、不足 

    1.有bug,在cell高度为50的时候,图片显示不了!(正在解决)

    2.使用 debug view  hierarchy (下图左下角第二个图标)发现 UI上有问题 cell 并不在同一个平面上(能力有限,还不清楚什么原因)

    效果:

    **************放弃下面的方法*******************

    ****2第三方库     SWTableViewCell   基本能够满足需求,但是有bug*****

    2.1 

      这个库在模拟器中运行有bug,真机也有bug

             

  • 相关阅读:
    VS安装部署
    C#与C/C++的交互
    3、C#入门第3课
    登录接口,猜年龄
    安装sql server 2016 always on配置dtc支持时遇到的问题
    购物车第一版
    Oracle patch查看路径
    innobackup增量备份脚本
    在vmware workstation下安装linux6关闭防火墙
    线程池-连接池-JDBC实例-JDBC连接池技术
  • 原文地址:https://www.cnblogs.com/tom2015010203/p/6732711.html
Copyright © 2011-2022 走看看