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来使用
     */
  • 相关阅读:
    POJ 2159 Ancient Cipher 难度:0
    POJ 3299 Humidex 难度:0
    POJ 1503 Integer Inquiry 大数 难度:0
    POJ 2262 Goldbach's Conjecture 数学常识 难度:0
    POJ 1083 Moving Tables 思路 难度:0
    PAT 甲级 1126 Eulerian Path
    Java 大数运算
    PAT 甲级 1010 Radix
    PAT 甲级 1137 Final Grading
    PAT 甲级 1064 Complete Binary Search Tree
  • 原文地址:https://www.cnblogs.com/StevenHuSir/p/10114631.html
Copyright © 2011-2022 走看看