This may sound like a weird question as obviously there is always viewForHeaderInSection
method available when working with tables in iOS.
However, to work with that function, one needs to reload the data of that table, something which I, in this case, want to avoid.
I have a button in my UITableViewSectionHeader
, and I want to disable it on a certain point in my app - again - without having to reload the tableview data.
I tried to do that with this piece code:
let currentTable = self.playerTables![i] as! UITableView
let header = currentTable.headerViewForSection(0)! as UITableViewHeaderFooterView!
let view = header.contentView as UIView
view.userInteractionEnabled = false
my app crashes when running this code, as the header
is nil when loading the contentView. It does initialize when I call the currentTable.headerViewForSection(0)!
code, but is nil again at the very next line.
I have checked whether the section i'm referring to is correct or not, checked apple docs and google/so and have not been able to find any reference on accessing the section header in the way I want. Is there a way?