zoukankan      html  css  js  c++  java
  • ViewWithTag-查找子控件报错

    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
    {
        // 求出标题按钮的索引
        NSUInteger index = scrollView.contentOffset.x / scrollView.width;
        // index == [0, 4]
        // 点击对应的标题按钮
        HKTitleButton *titleButton = self.titlesView.subviews[index];
        //HKTitleButton *titleButton = [self.titlesView viewWithTag:index];
        //此代码 索引为0时会报错(viewWithTag 递归查找,包括自己 先查找自己的tag,再查找子视图的tag,父视图默认tag为0,找到的是UIView而不是Button,所以setSelected方法找不到)
        [self titleButtonClick:titleButton];
    }

    此代码 索引为0时会报错(viewWithTag 递归查找,包括自己 先查找自己的tag,再查找子视图的tag,父视图默认tag为0,找到的是UIView而不是Button,所以setSelected方法找不到)

    /*
     -[UIView setSelected:]: unrecognized selector sent to instance 0x7fbcba35ab10
     
     -[HKPerson length]: unrecognized selector sent to instance 0x7fbcba35ab10
     将HKPerson当做NSString来使用
     
     - (void)test:(NSString *)string
     {
     string.length;
     }
     id str = [[HKPerson alloc] init];
     [self test:str];
     
     -[HKPerson count]: unrecognized selector sent to instance 0x7fbcba35ab10
     将HKPerson当做NSArray或者NSDictionary来使用
     
     -[HKPerson setObject:forKeyedSubscript:]: unrecognized selector sent to instance 0x7fbcba35ab10
     名字中带有Subscript的方法,一般都是集合的方法,比如NSMutableDictionaryNSMutableArray的方法
     将HKPersonNSMutableDictionary来使用
     */
  • 相关阅读:
    python pyinotify模块详解
    lastpass密码管理工具使用教程
    MAMP 环境下安装Redis扩展
    SourceTree使用方法
    Mac securecrt 破解
    Memcache 安装
    Warning: setcookie() expects parameter 3 to be long, string given
    SQLSTATE[HY000] [2002] Connection refused
    插件管理无法访问
    光栅化渲染器
  • 原文地址:https://www.cnblogs.com/StevenHuSir/p/10114631.html
Copyright © 2011-2022 走看看