So I have a subview called emptifier
in a TableViewController that is just an empty UIView and an empty sub-subview. I use emptifier
to hide the separator for the last cell in my tableview. But when I have an empty table, I want to push this subview to the back of the tableview hierarchy (behind all the other cells) so that I can actually see the separators and see that the tableview is empty.
So here is what I have in code:
func clearTable() {
/*
Clearing table code
*/
//To show the last cell's separator:
self.emptifier.superview!.sendSubviewToBack(self.emptifier)
}
And:
func loadTableResults() {
/*
Load Results code
*/
//To hide the last cell's separator:
self.emptifier.superview!.bringSubviewToFront(self.emptifier)
}
Now this should work perfectly, and I checked using print(tablview.subviews) that emptifier
is a subview of the table AND that it moves to the front/back of the table correctly. But for some reason, whatever order I set in the storyboard beforehand reins supreme, it's as if I don't have anything written in code.
My guess is that there is something having to do with tableviewcontrollers that I just don't understand and I just can't manipulate a tableview's subviews that way. But I tried to look it up and I couldn't find anything.