简体   繁体   中英

retrieve section from UIButton in Header view in section in UITableview

i have insert a UIButton in the header of the UITableView in every section, i want know if it's possible when pressed retrieve the section number, i add the button in this way:

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 309, 70)];

UIButton *markAllYes = [UIButton buttonWithType:UIButtonTypeCustom];

[markAllYes setImage:[UIImage imageNamed:@"mini_seen.png"] forState:UIControlStateNormal];
[markAllYes setFrame:CGRectMake(95, 35, 31, 31)];
[markAllYes addTarget:self action:@selector(markAllYesPressed:) forControlEvents:UIControlEventTouchUpInside];
[headerView addSubview:markAllYes];

return headerView;
}

您可以使用UIButton的tag属性。

markAllYes.tag = section

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM