【问题标题】:How can i put the image in the section of table in the titleForHeaderInSection method?如何将图像放在 titleForHeaderInSection 方法的表格部分中?
【发布时间】:2011-03-25 21:52:45
【问题描述】:

我很困惑在表格的标题部分制作图像, 我已经将图像放在表格的单元格中,但我不明白如何将图像放在表格的部分部分。 这是我的那个方法的代码..

  • (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

    如果(部分 == 0){

// return @"Alpahbets";带字符串

    UILabel *alphabet = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, 100)];
    alphabet.text = @"Alphabet";
    return alphabet.text;





} if (section == 1) {

// return @"罗马";带字符串 UILabel *roman = [[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 100)]; roman.text = @"罗马"; 返回 roman.text;

} else {

//  return @"Digits"; With String
    UILabel *digit = [[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 100)];
    digit.text = @"Digit";
    return digit.text;

}

}

【问题讨论】:

    标签: iphone


    【解决方案1】:

    您使用了错误的委托方法。来自UITableViewDataSource 的该委托方法仅允许您为默认节标题类型提供新的文本字符串。

    要将图像添加到您想要查看UITableViewDelete 方法的部分标题

    修改节的页眉和页脚
    – tableView:viewForHeaderInSection:
    – tableView:viewForFooterInSection:
    – tableView:heightForHeaderInSection:
    – tableView:heightForFooterInSection:

    使用这些,您可以为节的标题提供新视图(而不仅仅是文本)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-31
      • 2016-06-12
      • 2015-09-17
      • 1970-01-01
      • 1970-01-01
      • 2016-06-12
      • 1970-01-01
      相关资源
      最近更新 更多