Gie
Gie

Reputation: 1939

Width of UITableViewCell

I've project which is based on storyboard and on one of the views I've placed UITableView with UIViewTableViewCell (style Right Detail).

enter image description here

In Xcode everything looks OK, but when I launch application on simulator or device, the the table cell looks too wide.

enter image description here

Do you have any suggestions what could be reason of this strange behavior? What should I change to get cell be full visible?

EDIT:

I'm attaching cellforRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyTableCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;
}

Upvotes: 2

Views: 1422

Answers (2)

pls
pls

Reputation: 1532

I had the same problem where the content on the right hand side of my tableView was being cut off.

The reason being, I had set the Autolayout constraints correctly for the views inside my custom tableViewCell. However, I had not set the AutoLayoutConstraints for the tableView itself. Therefore the UITableView wasn't being constrained correctly and in my case was too large.

Upvotes: 0

SteBra
SteBra

Reputation: 4247

Have you put the same width for your custom cell, as the width of a UITableView?

enter image description here

Also, have you managed your "Delete" Label size properly (using autolayout or autoresizing). With new iPhone 6, we have to pay attention to widtch as well, just like with different heights, when iPhone 5 was introduced.

And I can see from those two screenshots you posted that you develop using iPhone6 sized ViewController and running it on iPhone5.

Im prety sure you didn't manage Autolayout / Autoresizing as you should.

Try doing this, for your "Delete" label:

enter image description here

Upvotes: 1

Related Questions