Why heightForHeaderInSection and heightForFooterInSection doesn't work in iOS 4.3 and it works in 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);
  }
有帮助吗?

解决方案

From Apple Docs

Prior to iOS 5.0, table views would automatically resize the heights of headers to 0 for sections where tableView:viewForHeaderInSection: returned a nil view. In iOS 5.0 and later, you must return the actual height for each section header in this method.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top