zoukankan      html  css  js  c++  java
  • IOS--在cell里面用代理实现和block一样的功能

    1. ....cell.h

    @class HMDownloadTableViewCell;
    
    @protocol HMDownloadTableViewCellDegate <NSObject>
    
    - (void)downloadTableViewCellNeedDelete:(HMDownloadTableViewCell *)cell;
    
    @end
    
    @interface HMDownloadTableViewCell : UITableViewCell
    @property (nonatomic, weak) id<HMDownloadTableViewCellDegate> delegate;
    @property (strong, nonatomic)  UIButton *deleteBtn;                     //删除按钮
    @end

    2.   ...cell.m

    //触发,这里是通过cell里面的按钮来触发的
    - (void)deleteBtnClick:(id)sender
    {
        if ([self.delegate respondsToSelector:@selector(downloadTableViewCellNeedDelete:)]) {
            [self.delegate downloadTableViewCellNeedDelete:self];
        }
    }

    3.  ...tableView.m

    <UITableViewDelegate, UITableViewDataSource, HMDownloadTableViewCellDegate>
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
      .....
      cell.delegate = self;    
       ....
    }
    
    #pragma mark - HMDownloadTableViewCellDegate
    - (void)downloadTableViewCellNeedDelete:(HMDownloadTableViewCell *)cell {
        NSLog(@"删除cell的书籍名字%@",cell.titleLabel.text);
    }
  • 相关阅读:
    点分治
    SG函数入门
    博弈论入门
    YY的gcd
    整除分块
    gcd约分函数的应用
    C++ 模拟类型(提高)
    C++数论题(博弈论)
    C++(gcd)的应用2。
    C++暴力约分(gcd).
  • 原文地址:https://www.cnblogs.com/qiyiyifan/p/7305531.html
Copyright © 2011-2022 走看看