.h
//声明代理
@protocol HselcellDelegate <NSObject>
//代理方法
-(void)dClickContinueBtn:(UIButton*)button;
@end
@interfaceTwoTableViewCell :UITableViewCell
//自定义的按钮
@property(nonatomic,strong)UIButton *bu;
//
@property (nonatomic, weak) id <HselcellDelegate>delegate;
@end
.m
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier{
self= [superinitWithStyle:stylereuseIdentifier:reuseIdentifier];
//自定义的按钮
_bu=[[UIButton alloc]initWithFrame:CGRectMake(HBScreenWidth-140, 24, 150, 20)];
[_bu setTitle:@"查看更多>" forState:UIControlStateNormal];
[_bu setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
[_bu addTarget:self action:@selector(continueBtnCilke:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_bu];
return self;
}
//代理的按钮实现
-(void)continueBtnCilke:(UIButton*)sender{
[self.delegate dClickContinueBtn:sender];
}
Controller.h
遵守协议
<HselcellDelegate>
//在cell中写的
cell2.delegate=self;
#pragma mark - 点击方法
-(void)dClickContinueBtn:(UIButton*)button
{
}