Created
December 5, 2015 11:42
-
-
Save jwthanh/67775d401e054ac046a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLayoutSubviews() { | |
super.viewDidLayoutSubviews() | |
// Dynamic sizing for the header view | |
if let headerView = tableView.tableHeaderView { | |
let height = headerView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height | |
var headerFrame = headerView.frame | |
// If we don't have this check, viewDidLayoutSubviews() will get | |
// repeatedly, causing the app to hang. | |
if height != headerFrame.size.height { | |
headerFrame.size.height = height | |
headerView.frame = headerFrame | |
tableView.tableHeaderView = headerView | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment