I’ve dragged a table view into my storyboard scene, but its height is static and won’t adjust based on how many cells it contains unless I manually adjust it in storyboard. How can I get this table to adjust its own height based on the total height of its contents?
Share
You’re going to have to do some version of this:
UITableViewBefore you get mad (since I know that’s pretty obvious), let me follow up with this:
UITableViewis a subclass ofUIView, you can simply adjust itsframeproperty.For example:
If you want to get really fancy, you can animate the change by wrapping it in a
[UIView animationWithDuration:]block.Hope this helps!
Update/Edit
Here’s a kludgy way to do it… it works, but I’m sure there’s a better way to do it. I do not claim this to be the best/fastest/most efficient way. This is more to show a principle. 😉