<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITableViewDelegate/tableView(_:viewForHeaderInSection:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UITableViewDelegate(im)tableView:viewForHeaderInSection:"
  },
  "title" : "tableView(_:viewForHeaderInSection:)"
}
-->

# tableView(_:viewForHeaderInSection:)

Asks the delegate for a view to display in the header of the specified section of the table view.

```
optional func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
```

## Parameters

`tableView`

The table view asking for the view.

`section`

The index number of the section containing the header view.

## Return Value

A [`UILabel`](/documentation/UIKit/UILabel), [`UIImageView`](/documentation/UIKit/UIImageView), or custom view to display at the top of the specified section.

## Discussion

If you implement this method but don’t implement [`tableView(_:heightForHeaderInSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:heightForHeaderInSection:)), the table view calculates the height automatically, or uses the value of [`sectionHeaderHeight`](/documentation/UIKit/UITableView/sectionHeaderHeight) if set.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)