zoukankan      html  css  js  c++  java
  • cell点击按钮崩的一种情况

    这个错误表示:该类方法没有addBtnClick对应的方法;

    bug的复现:创建一个cell,并且添加一个类方法来赋值,在方法中,给按钮添加一个点击事件(addBtnClick),但是,再实现这个方法时,我是用对象方法,所以会崩,应该改成类方法(即用 “+”):

    + (WDKAddFriendResultCell *)addFriendCellWithTableView:(UITableView *)tableView {

        WDKAddFriendResultCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WDKAddFriendResultCell"];

        if (cell == nil) {

            cell = [[[NSBundle mainBundle] loadNibNamed:@"WDKAddFriendResultCell" owner:nil options:nil] lastObject];

        }

        cell.addBtn.layer.borderColor = RGBA(0, 161, 176, 1).CGColor;

        cell.addBtn.layer.borderWidth = 0.5;

        [cell.addBtn addTarget:self action:@selector(addBtnClick) forControlEvents:UIControlEventTouchUpInside];

        return cell;

    }

    添加对应的方法:

    -  (void)addBtnClick {

        [YZTools toastMake:@"不会崩" isPush:NO];

    }------------------------这样是会崩的;

    应该改写如下:

    + (void)addBtnClick {

        [YZTools toastMake:@"不会崩" isPush:NO];

    }

  • 相关阅读:
    HDU1196 ZOJ2417 Lowest Bit
    HDU1008 ZOJ2108 Elevator
    HDU2614 Beat
    HDU2057 A + B Again
    POJ3984 迷宫问题
    HDU1013 POJ1519 Digital Roots
    HDU2051 Bitset
    HDU2037 今年暑假不AC
    ACM入门练习与递推小结
    HDU2046 骨牌铺方格【递推】
  • 原文地址:https://www.cnblogs.com/lyz0925/p/5672700.html
Copyright © 2011-2022 走看看