Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resize the UITableView's height dynamically?

Tags:

uikit

iphone

In my app, I would like to resize the tableview's height when it's in edit mode vs when it's not (in order to make room for editing controls below the table view)

How should this be done?

like image 421
Boon Avatar asked Aug 23 '09 08:08

Boon


2 Answers

I found that manipulating the "bounds" property can result in some unexpected behavior when you have a floating table inside another view. Sometimes the table expands upward when increasing the height, even though the origin is still 0,0.

The "frame" property might be more effective:

CGRect tvframe = [tableView frame];
[tableView setFrame:CGRectMake(tvframe.origin.x, 
                                tvframe.origin.y, 
                                tvframe.size.width, 
                                tvframe.size.height + 20)];
like image 182
Lavamantis Avatar answered Sep 20 '22 07:09

Lavamantis


You need to set the bounds of the tableview:

CGRect tvbounds = [tableView bounds];
[tableView setBounds:CGRectMake(tvbounds.origin.x, 
                                tvbounds.origin.y, 
                                tvbounds.size.width, 
                                tvbounds.size.height + 20)];
like image 20
rein Avatar answered Sep 23 '22 07:09

rein