• 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来使用
     */
  • 相关阅读:
    linux 下内存检查工具 valgrind 及 sanitizer 编译选项及静态检查工具
    jQuery中 inArray
    CLEAN crxMouse Gestures 插件被标记为不安全
    如何理解DMZ?
    如何完整备份浏览器数据(Chrome、Firefox)
    Windows 分屏工具
    JS监听H5返回
    华为账号安全性怎么样?
    IOS Safari keyup不生效如何解决?
    如何下载JD图片 不带logo图片?
  • 原文地址:https://www.cnblogs.com/StevenHuSir/p/10114631.html
Copyright © 2020-2023  润新知