自定义cell.h文件
@class ProductCollectionViewCell;
@protocol ProductCountDelegate <NSObject>
- (void)collectionCell:(ProductCollectionViewCell )cell btn:(UIButton)btn countLable:(UILabel *)countLable;
@end
@property (nonatomic) id<ProductCountDelegate> delegate; // 加减号代理方法
cell.m文件
button的点击方法中
(IBAction)btnClick:(UIButton *)sender {
if ([_delegate respondsToSelector:@selector(collectionCell:btn:countLable:)]) {
[_delegatecollectionCell:selfbtn:sender countLable:_countLable];
}
}
controller里实现签协议,tableview签代理 tableview. delegate = self;
实现代理方法
- (void)collectionCell:(ProductCollectionViewCell )cell btn:(UIButton )btn countLable:(UILabel *)countLable{