Ali Baqbani Ali Baqbani - 5 months ago 34
iOS Question

Get tableView from custom UITableViewHeaderFooterView

I have a problem iterating over custom

's superviews to get its ancestor
but it returns nil and does not reach
at all. This solution works with
cell though.

Please note that I use custom UITableViewHeaderFooterView with Nib for sectionHeader or footer.

This is my code to get super view:

var parentView = self.superview

while (parentView != nil && !(parentView is T)) {
parentView = parentView?.superview


I iterating the custom UITableViewHeaderFooterView's superviews when tableView not assigned itself to header view. So I override didMoveToSuperview() method in my class and my problem was gone.