Skip to content

Corner images fail to load under certain scenarios #3

Closed
@jhammer

Description

We ran into an edge case in our use of TORoundedTableView (which is awesome, by the way):

If -[TORoundedTableView layoutSubviews] is called before the table view has been added to the view hierarchy, then the rounded corner images are not loaded in time, and the table view cells do not have a rounded corner appearance.

Why does this happen? Well, -[TORoundedTableView layoutSubviews] results in a call to -[TORoundedTableViewCapCell didMoveToSuperview]. When TORoundedTableViewCapCell tries to get the table view's roundedCornerImage in -[TORoundedTableViewCapCell didMoveToSuperview], it won't be able to because the table view hasn't loaded them yet (which happens only once the table has been added to the view hierarchy in -[TORoundedTableView didMoveToSuperview]).

My suggested fix is to eagerly call loadCornerImages inside of -[TORoundedTableView setUp], rather than lazily in -[TORoundedTableView didMoveToSuperview]. This solved the problem for us.

The question you're probably asking is, why would layoutSubviews be called before the table is added to the view hierarchy? We ran into a situation where we have a table header view that is sized using auto layout and, in order for it to display correctly when the table first appears, we have to call -[UITableView layoutIfNeeded] inside our view controller's viewDidLoad method. This triggers all of the layout, even though the table view doesn't have a superview yet.

Thanks for considering this fix.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions