iOS delegate传值
#import <UIKit/UIKit.h>
#import "MineHeadModel.h"
NS_ASSUME_NONNULL_BEGIN
@protocol HeadViewDelegate <NSObject>
- (void)headViewButtonClick:(NSInteger)index;
@end
@interface HeadView : UIView
@property (nonatomic, weak) id<HeadViewDelegate> delegate;
@property (nonatomic, strong) MineHeadModel *model;
@end
- (void)buttonClick:(UIButton *)button
{
if (self.delegate && [self.delegate respondsToSelector:@selector(headViewButtonClick:)]) {
[self.delegate headViewButtonClick:button.tag];
}
}
HeadViewDelegate
@property (nonatomic, strong) HeadView *headerView;
- (HeadView *)headerView
{
if(!_headerView){
_headerView = [[HeadView alloc]init];
_headerView.delegate = self;
}
return _headerView;
}
#pragma mark - HeadView上按钮点击的回调方法
- (void)headViewButtonClick:(NSInteger)index{
}