Reputation: 6940
I have UITableView connected through delegate like that:
Everything work fine. But i need to change height of UITableView dynamically, based on content of other UI elements. Following doesnt work:
/* UITableView Frame */
CGRect newFrame = CGRectMake(10, 10, 300, 200);
self.spotlightTableView.frame = newFrame;
Its always use frames, that i set in StoryBoard. How to fix that?
Upvotes: 1
Views: 3379
Reputation: 1841
you should set the frame in viewDidLayoutSubviews
. You can also do it in viewWillAppear
but you should note that viewDidLayout
is called every time a layout occurs (e.g. device rotation) while viewWillAppear
is not.
Upvotes: 3
Reputation: 2303
Where in your code do you set this new frame ?
Anyway, you should really be using autolayout / contraints to dynamically adapt your table view frame based on other UI elements.
Upvotes: 0