Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically determining padding for grouped UITableView

Is there a way to programmatically get a UITableView's 'grouped' style padding?

I'd like to size some things in my screen but I need to know how far left or right to place them on a grouped UITableView's UITableViewCell.

like image 563
Luther Baker Avatar asked Apr 24 '10 13:04

Luther Baker


2 Answers

Since you are using the grouped style for your table view, you should be able to use the rectForSection: method to get the CGRect where that section will be drawn. You may have to already have added your cells to your view, however.

CGRect sectionRect = [tableView rectForSection:0];
int paddingLeft = sectionRect.origin.x;
like image 93
highlycaffeinated Avatar answered Oct 05 '22 03:10

highlycaffeinated


As I see it, 'grouped' style padding == the origin of cell.contentView. but the value is assigned by table view only in tableView:willDisplayCell:forRowAtIndexPath: and is equal to 10 on iPhone/iPod Touch. querying it in cellForRowAtIndexPath: results in 0.

like image 31
Russian Avatar answered Oct 05 '22 03:10

Russian