Ali Baqbani Ali Baqbani - 1 year ago 134
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download