I have a table with custom header views that no matter when, or what value I choose for section, I always get nil value. I have another table with the same problem.
From the docs:
To make the table view aware of your header or footer view, you need to register it. You do this using the
registerNib:forHeaderFooterViewReuseIdentifier:orregisterClass:forHeaderFooterViewReuseIdentifier:method ofUITableView.
(The Swift equivalent is register(_:forHeaderFooterViewReuseIdentifier:).)
So you need to register the nib, and then get it using a reuse identifier, instead of pulling it straight out of the app bundle, which is what you're doing now.
...if you want to use the headerViewForSection method.
Alternatively, you could check whether to keep spinning inside the viewForHeaderInSection method and then send just call:
[self.tableView beginUpdates];
[self.tableView endUpdates];
To refresh the section header.
(Note that this alternative approach will destroy and recreate your whole view, so if you have a big table with lots of data, it may not be very efficient.)