开发者

Resizing TableViewCell when TableView is in grouped mode

开发者 https://www.devze.com 2022-12-19 05:30 出处:网络
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

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 Bu开发者_Python百科ilder 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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号