Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the size of UITableView programmatically

Tags:

ios

ios5

I am trying to display data from a mysql database on my server. I am loading the data into a table. The problem is, I don't want this data to be the only thing on the view. I want the table to be shared with other content. Ideally, I would like the table to be able to grow and expand with how many cells their are. So if there are 3 cells, I would like it to grow to fit all 3. If there are 10, I would like it to grow to fit all 10.

It looks like Apple does this a lot. A major place I notice it is in their contacts, the phone numbers table grows and shrinks depending on how many numbers there are.

like image 807
Keith Avatar asked May 25 '12 18:05

Keith


1 Answers

with bellow code your tableview size decide with its content...

tableView.frame = CGRectMake(tableView.frame.origin.x, tableView.frame.origin.y, tableView.frame.size.width, tableView.contentSize.height);
like image 149
Paras Joshi Avatar answered Oct 18 '22 23:10

Paras Joshi