为什么heightForHeaderInSection在iOS 4.3中不起作用?

时间:2012-04-06 20:38:43

标签: iphone cocoa-touch ipad uitableview objective-c-2.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);
  }

1 个答案:

答案 0 :(得分:9)

来自Apple Docs

  

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