Uitableview with Fixed Section Headers

UITableView with fixed section headers

The headers only remain fixed (floating) when the UITableViewStyle property of the table is set to UITableViewStylePlain.

If you have it set to UITableViewStyleGrouped, the headers will scroll up with the cells (will not float).

UITableview: Fixed Section Headers

You should add separate tableViews instead of sections in same tableView. That way your tableView's frame will be fixed and adding row to either won't push others frame down.

Is it possible to have a fixed uitableview Header while using sections?

There’s no way to maintain the header of a tableView fixed, but
an useful approach when you need a unique header, is to use a UIViewController rather than a UITableViewController, and set the header (UIView) out from the tableView.

Something like this:

Sample Image

How to set specific section header in UITableView [Swift]

Use switch-case makes better code

func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
switch section {
case 0: return "Section 0"
case 1: return "Section 1"
default: return nil
}
}

Ungrouping UITableView Section Header when Header is top of view

I am not completely sure I follow what you are trying to accomplish, but please allow me to attempt to infer and feel free to provide clarifications. I like the table view practice :)

As I understand it:

1) You want the white view, the red view, and the table cells beneath the red view to scroll upward from the default position

2) You want the white view to scroll out of visibility

3) You want the red view to float at the top while the cells scroll beneath it

4) You currently have the white view as a table header, the red view as a section header, and the gray area are table cells

Sounds like a cool app!

Why not use 2 table sections:

1) Drop the table header

2) Set the white view in cell 0 section 0 of the table view.

3) Set table delegate methods so section 0 will have a nil header with 0 height

3.5) Also set the table delegate methods so section 1 will be your main table

4) Use UITableViewStylePlain so section 1 header will float at the top

Is this the desired functionality?

Extra padding above table view headers in iOS 15

Since iOS 15, UITableView contains a new property called sectionHeaderTopPadding which specifies the amount of padding above each section header.

tableView.sectionHeaderTopPadding = 0.0

Note: This applies only to the UITableView.Style.plain.



Related Topics



Leave a reply



Submit