How to adjust custom xib width of UITableViewCell according to device width

I am creating UITableTableViewCell

from nib file. I am using 320 width for the cell width. I found that when I run the application in the simulator iphone 6

, the cell cannot take up the full width of the table view. If I am using iphone 5s the width is just fine. I want to know how to adjust the xib width to fit different iPhone versions.

+3


source to share


3 answers


Have you enabled Use Auto Layout and Use Size Classes as shown below, as shown below, both in table view and table view. And tell me your problem

enter image description here

1) After that select an image and a label and do as shown below

enter image description here

2) Select an image and do below



enter image description here

3) select a label and do as follows

enter image description here

You can check the link below:

iOS - Custom table cell not full width UITableView

+4


source


The problem might be that the table view is not stretching to fit the screen width and the row resizes to that wrong width.

With the table display selected in your storyboard, make sure all red constraint handles are selected so that it can resize in all directions.



enter image description here

0


source


It seems like your table doesn't take up the full width of the screen. First, set the border as a table:

[[tblList layer]setBorderColor:[UIColor grayColor].CGColor];
[[tblList layer]setBorderWidth:2.0];

      

Check it out first. Then add a comment. In fact I am setting an auto-detection limit on my table view and keep the width of my custom one UITableViewCell

to 320. It automatically covers the full width of the screen.

-1


source







All Articles