• UItableViewCell滑动删除时,调整cell子视图的位置大小


    UItableViewCell滑动删除时,调整cell的位置大小是否显示等。
    CustomTableViewCell为UITableViewCell的子类,在实现文件中重写willTransitionToState方法。
    willTransitionToState是在cell改变显示状态的时候调用,有三种状态:
    typedef NS_OPTIONS(NSUInteger, UITableViewCellStateMask) {
    UITableViewCellStateDefaultMask = 0, //普通状态
    UITableViewCellStateShowingEditControlMask = 1 << 0, //编辑状态
    UITableViewCellStateShowingDeleteConfirmationMask = 1 << 1 //删除状态
    };
    具体实现方法:

    - (void) willTransitionToState:(UITableViewCellStateMask)state{
        [super willTransitionToState:state];
        //UITableViewCellStateShowingDeleteConfirmationMask
        if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) {
            for (UIView *subview in self.subviews) {
                if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
                    //this is delete button
                }
                
                if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellContentView"]) {
                    //this is contentView
                    for (UIView *sub in subview.subviews) {
                        if ([NSStringFromClass([sub class]) isEqualToString:@"UILabel"]) {
                            UILabel *subLabel = (UILabel *)sub;
                            if (subLabel.tag == 8) {
                                subLabel.hidden = YES;
                            }
                        }
                        if ([NSStringFromClass([sub class]) isEqualToString:@"UIImageView"]) {
                            UILabel *subImageView = (UILabel *)sub;
                            if (subImageView.tag == 11) {
                                subImageView.hidden = YES;
                            }
                        }
                    }
                }
            }
        }
        //UITableViewCellStateDefaultMask
        if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateDefaultMask){
            for (UIView *subview in self.subviews) {
                if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
                    //this is delete button
                }
                
                if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellContentView"]) {
                    //this is contentView
                    for (UIView *sub in subview.subviews) {
                        if ([NSStringFromClass([sub class]) isEqualToString:@"UILabel"]) {
                            UILabel *subLabel = (UILabel *)sub;
                            if (subLabel.tag == 8) {
                                subLabel.hidden = NO;
                            }
                        }
                        if ([NSStringFromClass([sub class]) isEqualToString:@"UIImageView"]) {
                            UILabel *subImageView = (UILabel *)sub;
                            if (subImageView.tag == 11) {
                                subImageView.hidden = NO;
                            }
                        }
                    }
                }
            }
        }
    }
    

      

  • 相关阅读:
    Ubuntu 14 如何解压 .zip、.rar 文件
    python 自定义异常
    python 简单的自定义异常类模版
    python 获取文件目录位置
    python获取当前文件路径以及父文件路径
    python tar 打包
    python requests 上传文件
    android:ems="10"是什么意思
    django 应用中获取访问者ip地址
    curl: (6) Could not resolve host: www.baidu.com;
  • 原文地址:https://www.cnblogs.com/nanoCramer/p/3140255.html
Copyright © 2020-2023  润新知