Alexis
Alexis

Reputation: 16829

How to calculate the size of cell in UITableView when using grouped style?

I'm working on a universal app and the view I'm working on is common to iPhone and iPad. I display a UITableView (with grouped style) and I made a custom cell (programmatically - no nib). I read somewhere (can't find where anymore) that the margins are of 1/16 * width of the table. So I set the width of my custom cell to 14/16 * width of the table but that's not good. Or at least it doesn't work well.

Can someone confirm or invalidate that the margins are 1/16 * width of the table?

And in the case that's not 1/16, how can compute that size?

Upvotes: 1

Views: 683

Answers (2)

JP Hribovsek
JP Hribovsek

Reputation: 6707

iPhone portrait margins : 10 pixels
iPhone landscape or iPad margins:
- if table width<400 then 10 pixels
- else margin = 6% of table width, with minimum of 31 pixels, max of 45 pixels

Upvotes: 2

elk
elk

Reputation: 31

I believe the default horizontal margin is 10 pixels. But you could use auto resizing, eg UIViewAutoresizingFlexibleWidth. Look at the UIView documentation.

Upvotes: 0

Related Questions