Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 784
nikunj492 Avatar asked Oct 14 '14 10:10

nikunj492


2 Answers

You will find the width with the tableview size and it's 44px on height by default, so you can override initWithStyle method and add tableview width parameter.

like image 92
houguet pierre Avatar answered Sep 23 '22 06:09

houguet pierre


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.

like image 33
hybridcattt Avatar answered Sep 23 '22 06:09

hybridcattt