---
title: "tableView(_:viewForHeaderInSection:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitableviewdelegate/tableview(_:viewforheaderinsection:)"
---

# tableView(_:viewForHeaderInSection:)

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

## Declaration

```swift
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.

## Mentioned in

Adding headers and footers to table sections

## Return Value

Return Value A UILabel, UIImageView, or custom view to display at the top of the specified section.

## Discussion

Discussion If you implement this method but don’t implement tableView(_:heightForHeaderInSection:), the table view calculates the height automatically, or uses the value of sectionHeaderHeight if set.

## See Also

### Providing custom header and footer views

- [tableView(_:viewForFooterInSection:)](uikit/uitableviewdelegate/tableview(_:viewforfooterinsection:).md)
- [tableView(_:willDisplayHeaderView:forSection:)](uikit/uitableviewdelegate/tableview(_:willdisplayheaderview:forsection:).md)
- [tableView(_:willDisplayFooterView:forSection:)](uikit/uitableviewdelegate/tableview(_:willdisplayfooterview:forsection:).md)
