zoukankan      html  css  js  c++  java
  • 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;
                            }
                        }
                    }
                }
            }
        }
    }
    

      

  • 相关阅读:
    C#下载文件代码更新20070920
    判断IP地址是否合法的sql2000使用存储过程跟函数
    百万级SQL分页存储过程
    C#批量重命名文件代码的实现
    单个分页的存储过程
    阿江网站访问统计系统设计构思分析
    c#查询QQ状态是否在线查询代码
    C# public class Person
    C#禁止应用程序的多重运行
    Outlook最小化到托盘的设置方法
  • 原文地址:https://www.cnblogs.com/nanoCramer/p/3140255.html
Copyright © 2011-2022 走看看