IOS will change the height of a uitableview

I need to dynamically change the height of a uitableview inside my view.

I tried with this code inside viewDidLoad:

self.theTable.rowHeight = 90; self.theTable.contentSize = CGSizeMake(320,900); 

The first line works and the height changes, but the second does not work!

How can i do this?

+6
source share
3 answers

You can try dropping borders as follows:

 CGRect bounds = [tableView bounds]; [tableView setBounds:CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height + 20)]; 
+13
source

It worked for me.

 self.myTableView.frame = CGRectMake(0,40,320,480); 
+8
source

Please note that you can change the height of a UITableView by simply adjusting it in viewDidAppear or viewDidLoad.

However, if you want to change the height of the tableView after this point (for example, when someone clicked a button), this is not possible for tableViews created in the Storyboard. You can change the height after loading the table for table programs created programmatically.

+1
source

Source: https://habr.com/ru/post/892353/


All Articles