Cell中添加Button
自定义cell,在cell中添加Button控件,添加对应相应事件,然后从cell的.h文件中声明个代理
@protocol SHFenleiCellDelegate <NSObject>
- (void)didQueRenBtn:(UIButton *)button atIndex:(NSInteger)index;
@end
在cell的model赋值方法中添加个index参数
/**
* @parm modelStatus 赋值用的model
* @parm indxe 对应cell的indexPath.row
*/
- (void)setModelStatus:(YCGJGongZuoModel*)modelStatus index:(NSInteger)index;
接下来再在.m中实现
- (void)setModelStatus:(YCGJGongZuoModel*)modelStatus index:(NSInteger)index
{
// 需要提前在.h中声明一个变量接收index
_index = index;
}
然后在.m中的Button点击事件中添加代码
- (void)tapConfirmBtn:(id)sender
{
// 之前声明好的代理
if ([self.delegate respondsToSelector:@selector(didQueRenBtn: atIndex:)]) {
[self.delegate didQueRenBtn:sender atIndex:_index];
}
}
然后再在Controller中用之前代理的方法就ok了。