views:

182

answers:

2

I have a TableView in my application and I've created a centered label inside TableViewCell that I'm placing in the view. When TableView is in standard mode everything is ok and the label is really centered. However when I change the mode to grouped then the label is displayed slightly to the right. I suspect this is because in grouped mode the table is a bit shorter then in standard mode and since I've centered it for standard view in Interface Builder it's just being moved to the right.

I'd like to know if there's a way to automatically have centered TableViewCell label adjust it's parameters so it appears centered in grouped TableView or do I need to make it a bit shorter and move it a bit to the left manually to get what I want?

+1  A: 

Assuming that the table will be initialized with a centered label, it should respond properly to future changes in width when you set its autoresizingMask to UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin. But as far as I know you can't change a table's style after creation, so I'm not sure if this approach will fix your problem.

MrMage
I don't want to change table style after creation. It's just that I first created a table and cells for it in normal view and now I've decided that I prefer grouped view so I was wondering if I need to manually edit all my cells to fit the table. I'll give a shot with what you've described above. Many thanks.
RaYell
Unfortunatelly this doesn't solve the problem.
RaYell
A: 

I've found a solution. I'm not very happy with it but it works. I just resized TableViewCell and it's contents to 300px width instead of default 320 and it fits ok.

RaYell