Created
December 12, 2014 12:24
-
-
Save florianbuerger/c08bd42b91b6c231c870 to your computer and use it in GitHub Desktop.
Is there a better way to create a UITableView.footerView where you don’t know the height when you create it?
This file contains hidden or 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
let footer = TableFooterView(frame: CGRectZero) | |
footer.addButtonWithTitle("Red", backgroundColor: UIColor.redColor(), target: self, action: "redWasPressed:" as Selector) | |
footer.addButtonWithTitle("Green", backgroundColor: UIColor.greenColor(), target: self, action: "greenWasPressed:" as Selector) | |
footer.addButtonWithTitle("Blue", backgroundColor: UIColor.blueColor(), target: self, action: "blueWasPressed:" as Selector) | |
footer.updateConstraintsIfNeeded() | |
footer.layoutIfNeeded() | |
footer.frame = CGRectMake(0, 0, footer.intrinsicContentSize().width, footer.intrinsicContentSize().height) | |
tableView.tableFooterView = footer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We can’t add constraints to the footerView itself because its size is managed by the
UITableView
. You can try but the result won’t be what you’d expect.