0

为什么 heightForHeaderInSection 和 heightForFooterInSection 在 iOS 4.3 中不起作用而在 5.0 中起作用?

  -(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
  {
     if (section == 0) {
        return 10.0;
     }
     return (tableView.sectionHeaderHeight - 20);
  }

  -(CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section
  {
     if (section == ([self.optionsArray count] - 1)) {
        return 15.0;
     }
     return (tableView.sectionFooterHeight - 20);
  }
4

1 回答 1

9

来自 Apple 文档

在 iOS 5.0 之前,对于 tableView:viewForHeaderInSection: 返回 nil 视图的部分,表视图会自动将标题的高度调整为 0。在 iOS 5.0 及更高版本中,您必须在此方法中返回每个节标题的实际高度。

于 2012-04-06T20:41:51.103 回答