我想在部分标题中放置一个信息灯按钮
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 20;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *sectionHeaderView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 20)];
UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
infoButton.frame = CGRectMake(0, 0, 18, 18); // x,y,width,height
infoButton.enabled = YES;
[infoButton addTarget:self action:@selector(infoButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
//Add the subview to the UIView
[sectionHeaderView addSubview:infoButton];
return sectionHeaderView;
}
- (void)infoButtonClicked:(id)sender {
NSLog(@"infoButtonClicked");
}
按钮没有响应。我不太清楚为什么。这可能是一件容易的事。任何帮助,将不胜感激。