views:

312

answers:

3

Basically, I want to create a button underneath a grouped table view, like contacts.app has to delete contacts.

I can create the button fine, I'm just a bit puzzled as to how to decide where to put it.

I thought I could just do:

CGRect bounds = [[self tableView] bounds];

Then place the button based on that.

However, when accessing the size.height of bounds I get zero! Is there a dynamic way to retrieve the tableView's height that I could be missing?

Any help is greatly appreciated.

Rich

A: 

You can get the tablewViews heigh by looking at its frame

CGRect bounds= [[self tableView] frame]; 
float heigh= frame.size.height;
Daniel
I think that'll give you the height of the scrollview, not the actual content of the table; so if you wanted to add views that are off screen that wouldn't work.
Kevlar
A: 

You could try making a custom footer view with those buttons placed in that view by implementing these methods:

- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

That should let you put any number of buttons on your table underneath the section you want.

Kevlar
+2  A: 

You can create the size of your button like

CGRect buttonFrame = CGRectMake(0, 0, width, height);

Create the button with that frame, and then set the button as the tableView's footer

myTableView.tableFooterView = myButton;
jbrennan
That works exactly as I want it to! Thanks :D
Rich