简体   繁体   中英

Default Width of UITableViewCell in iphone 6

In iphone 6, I am making a custom UITableViewCell. In init function when I do,

self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

And then , I check the frame it comes out to be 320 X 44 instead of 375 X 44 . However, in layoutSubviews , it comes fine. I am checking this on iphone 6 simulator. Is there a way I can get the correct size in init only ?

您将发现带有tableview大小的宽度,默认情况下高度为44px,因此您可以覆盖initWithStyle方法并添加tableview width参数。

I suppose you can't. Same issue has been following the iPad for the last few years, and I don't believe anything has changed now. New cell always has 320 px width at first. You can implement some custom logic, such as laying out subviews not depending on current bounds, but on desired future bounds.

But anyway, if you're adapting the interface to iPhone 6 & 6 Plus, you obviously also support iPhone 5, which has width 320px. Then just create "resizable" cell that looks good with any cell width.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM