【问题标题】:retrieve section from UIButton in Header view in section in UITableview在 UITableview 部分的 Header 视图中从 UIButton 检索部分
【发布时间】:2013-08-03 11:43:55
【问题描述】:

我在每个部分的 UITableView 的标题中插入了一个 UIButton,我想知道按下时是否可以检索部分编号,我以这种方式添加按钮:

- (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;
}

【问题讨论】:

  • 使用类似 markAllYes.tag = 部分的标签并使用 markAllYes.tag 按钮标签进行访问。

标签: ios objective-c uitableview


【解决方案1】:

您可以使用 UIButton 的 tag 属性。

markAllYes.tag = section

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-14
    • 1970-01-01
    • 2010-12-26
    • 2010-12-20
    相关资源
    最近更新 更多