zoukankan      html  css  js  c++  java
  • iOS tableView 选中某个cell时 标准的处理方法

    以前选中cell时,常常判断选中的行数,但是当cell的顺序发生变化时,就要改动处理函数,特别是行数比较多的时候,很麻烦。

    之后运用cell的title的内容判断,但是这种判断与现实的内容密切相关,如果改了title内容,也需要改动处理代码,也不正规。

    最标准的方法是,声明一个枚举类型,enum,这样如果改动了cell的顺序,只需要改动enum的定义就可以。

    代码如下:

    typedef NS_ENUM(NSInteger, MMProgressHUDDemoFeatureType) {
    
        MMProgressHUDDemoTypeStylePlain = 0,
    
        MMProgressHUDDemoTypeStyleBordered,
    
        MMProgressHUDDemoTypeStaticImage,
    
        MMProgressHUDDemoTypeAnimatedImage,
    
        MMProgressHUDDemoTypeAutosizing,
    
        MMProgressHUDDemoTypeConfirmation,
    
        MMProgressHUDDemoTypeRadialProgress,
    
         MMProgressHUDDemoTypeLinearProgress,
    
        MMProgressHUDDemoTypeOverlayColor,
    
        MMProgressHUDDemoTypeImageRemove,
    
    };
    
     switch (indexPath.section) {
    
            caseMMProgressHUDDemoSectionFeatures:
    
                switch (indexPath.row) {
    
                    caseMMProgressHUDDemoTypeAnimatedImage:                    
    
                        break;
    
                    caseMMProgressHUDDemoTypeAutosizing:                  
    
                        break;
    
                    caseMMProgressHUDDemoTypeConfirmation:
    
        }
       break;
    
    }                   

                       

  • 相关阅读:
    Codeigniter 控制器的继承问题
    laravel 安装
    js preventDefault() 方法
    jquery 获取$("#id").text()里面的值 需要进行去空格去换行符操作
    HDU_1394_线段树
    Codeforces_723_D
    Codeforces_723_C
    Codeforces_723_B
    Codeforces_723_A
    HDU_4456_二维树状数组
  • 原文地址:https://www.cnblogs.com/breezemist/p/3487887.html
Copyright © 2011-2022 走看看