Customer Class

1.自定义UITableViewHeaderFooterView

头文件:

#pragma mark - ClickedHeader

@interface ClickedHeader : UITableViewHeaderFooterView

@property (assign)BOOL clicked;
@property (assign)uint32_t section;

@property (nonatomic, strong) UIButton* button;

- (id)initWithClickedHeaderReuseIdentifier:(id)sender;

@end

实现文件:

#pragma mark - ClickedHeader

@implementation ClickedHeader

- (id)initWithClickedHeaderReuseIdentifier:(id)sender
{
    self = [super initWithReuseIdentifier:ClickedHeaderReuseIdentifier];
    
    if (self)
    {
        _clicked =  false;
        
        self.button = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.button setFrame:CGRectMake(0, 0, WIDTH, CLICK_BUTTON_HEIGHT)];
        [self.button setBackgroundColor:[UIColor lightGrayColor]];
        [self.button addTarget:self
                        action:@selector(buttonClicked:)
              forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.button];
    }
    
    return self;
}

- (void)buttonClicked:(id)sender
{
    _clicked = !_clicked;
    
    ClickedMarked* obj = [[ClickedMarked alloc] initWithSection:self.section
                                                     andClicked:self.clicked];
    NSNotificationCenter* noti = NULL;
    noti = [NSNotificationCenter defaultCenter];
    [noti postNotificationName:kReloadTableNotification object:obj];
}

@end

这里注意的是,重用的是一个固定标志符,所以直接self = [super initWithReuseIdentifier: XXXXXXXX]; 即可,并不用传参。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值