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

kee*_*you 0 iphone cocoa-touch uitableview objective-c-2.0 ipad

为什么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);
  }
Run Code Online (Sandbox Code Playgroud)

Oti*_*ium 9

来自Apple Docs

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