0

I am having a weird issue where my custom cell labels show up in what would be the correct position, but the custom cells otherwise are not loading. I am creating a Universal app, and my iPhone and iPad share all code but the storyboards. The iPhone version works fine.

Here is a picture of the custom cell: enter image description here

And here is what it looks like on the iPad when I run it: enter image description here

I have recreated the TableViewController from scratch, the cells from scratch, rehooked everything up, and triple checked again and again. The class is assigned (obviously because the labels change), and it all looks swell.

Like I said, the identical setup works just fine on the iPhone storyboard.

Notice the small Discloser Indicator on the top cell. The segue works from the top line there, as it should.

Why is it creating this weird layout? Thanks!

Siriss
  • 3,737
  • 4
  • 32
  • 65
  • Do you implement `tableView:heightForRowAtIndexPath:`? – Jon Brooks Apr 27 '14 at 20:21
  • I do not, as I was under the impression that it will use the height set in storyboard. It works fine with iPhone. Do you need to set that in order to use two storyboards with one tableview class? – Siriss Apr 27 '14 at 20:36
  • I can't explain why it would work on one and not the other. I recall having issues with it in the past, and a brief scan through my code shows that I generally implement it even for custom cells defined in a nib. Do you define the constraints on the cell the same in both storyboards? – Jon Brooks Apr 27 '14 at 20:43
  • Yeah, everything is identical in both storyboards,except the cell size and font size to better fit the larger screen. It will be difficult in my setup to have to implement that. I guess I have to start exploring it though. – Siriss Apr 27 '14 at 20:53
  • Bug in Xcode? The labels working is really making me wonder. – Siriss Apr 28 '14 at 00:09

1 Answers1

1

I think you'll have to implement either the delegate method tableView:heightForRowAtIndexPath: or setting the rowHeight property on the tableView as explained here.

As to why it works on iPhone, perhaps it just happens to be a good size. Apple docs for rowHeight state:

If you do not explicitly set the row height, UITableView sets it to a standard value.

Community
  • 1
  • 1
Jon Brooks
  • 2,472
  • 24
  • 32
  • It is interesting. The iPhone is certainly not a standard size cell, so it is pulling the size from the storyboard. I have done this in previous iphone apps, and it has worked as well, but this is my first universal one, so that could be the issue. I'll check it out. Also, why would the labels appear to be in the correct spot? Some part of it is working..... – Siriss Apr 28 '14 at 00:08
  • You are correct. The rowHeight value was not taking. Interestingly it was set in code, and should have overridden the storyboard, but it seems the storyboard was winning. I am still going to explore this. Thanks, for helping me with my brain melt. – Siriss Apr 28 '14 at 03:10