自定义的UICollectionViewCell 无XIB,for循环创建btn 用代理设置btn的绑定事件无效怎么回事?

我用了代理 为什么点击事件没作用?

#import <UIKit/UIKit.h>
#import "AFNetWorkingTool.h"


@protocol FristSectionCollectionViewCellDelegate <NSObject>

@required
-(void)choseTerm:(UIButton *)button;
-(void)changeButtonBackgroundColor:(UIButton *)button;
@end


@interface FristSectionCollectionViewCell : UICollectionViewCell

@property(nonatomic,strong)UIButton *eight;

@property(nonatomic,assign)id<FristSectionCollectionViewCellDelegate> delegate;
-(void)eight_btn_click:(UIButton *)btn;

@end




#import "FristSectionCollectionViewCell.h"


@implementation FristSectionCollectionViewCell
-(id)initWithFrame:(CGRect)frame{

     
        for (int i = 0; i <8; i ++) {
            _eight_btn = [UIButton buttonWithType:UIButtonTypeCustom];
            _eight_btn.tag = i;
            _eight_btn.frame = CGRectMake(坐标);
            [self.contentView addSubview:_eight_btn];

                
  
            [self.eight_btn addTarget:self action:@selector(eight_btn_click:) forControlEvents:UIControlEventTouchUpInside];

            }
            }
            
            
-(void)eight_btn_click:(UIButton *)btn{
    if ([_delegate respondsToSelector:@selector(choseTerm:)]) {
        [_delegate choseTerm:btn];
    }
}

#import "MainViewController.h"
@interface MainViewController ()

-(void)choseTerm:(UIButton *)button{
                    NSLog(@"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  %ld",(long)button.tag);
}
查看回复