2

Just to preface, this issue is similar to the problem of constraints being ignored in prototype cells, but I have tried all of the recommendations on this site and none have worked. I've tried:

My app uses xib/nib files, which I guess makes it even more of a pain for fixing.

I have set up the table inside of a UIView and included a prototype cell that is connected to the xib, like so:

enter image description here

enter image description here

I added constraints for each element and even made sure that xcode added any I forgot. I did not use stack view, because when I do it collapses everything on top of one another.

enter image description here

However, regardless of what I try, when I go to run it, I still get this:

enter image description here

The view, is a UIView in the Interface builder. The table is a UITableView. The prototype cell is a EpisodeTableViewCell (name of the xib). And the Xib is a EpisodeTableViewCell.

Attempts that did not work:

  • Setting the prototype cell to standard UITableViewCell
  • Removing the prototype cell
  • Setting more constraints
  • Setting stack layout
  • Various attempts to more closely link the xib and the main views.

And some other stuff I've tried that I'm not remembering at this time. I've been trying to fix this for days now. I'm open to any new suggestions.

Thanks in advance.

UPDATE WITH XIB INFO

The xib is connected through the prototype cell and some code. The prototype cell is set as the name of the xib, but is also a button to direct the user to the next view.

enter image description here

enter image description here

episodeListTableView.delegate = self
    episodeListTableView.dataSource = self
    episodeListTableView.register(UINib(nibName: "EpisodeTableViewCell", bundle: nil), forCellReuseIdentifier: "SingleEpisodeTableViewCell")

enter image description here

adazebra
  • 68
  • 2
  • 9
  • Can you share your cell nib code? I think issue is with constraints. If not then probably the hight for `UITableViewCell` is wrong. – Umair Aamir Jan 09 '18 at 21:13
  • Apparently, the UI for your cell can also be achieved by setting your cell style to `Subtitle` Don't need to create a custom one. Not sure though. – Umair Aamir Jan 09 '18 at 21:17
  • Most people with similar issues didn't find that it was a code issue. Just some weird problem with Interface builder. But changing the height using self.tableView.rowHeight = UITableViewAutomaticDimension self.tableView.estimatedRowHeight = 120 // Any referencial height Doesn't actually work in this instance. – adazebra Jan 09 '18 at 21:26
  • *"a prototype cell that is connected to the xib"* ... how are you doing that? Generally, one uses XIB files *instead of* Storyboards and prototypes. I just did a quick test, and using `tableView.register(UINib(nibName: "SingleEpisodeTableViewCell", bundle: nil), forCellReuseIdentifier: "SECell")` I have no problem with auto-layout respecting the constraints. – DonMag Jan 09 '18 at 21:49
  • Unfortunately, without the prototype cell, I can't use the cell as a button to the next view, or I would just do away with the prototype all together. I included some new images above for more detail about the xib connection. – adazebra Jan 09 '18 at 21:56
  • I guess the question becomes, if this is an error in xcode somehow because I have some random thing set improperly somewhere, do I just need to set all the constraints programmatically? – adazebra Jan 09 '18 at 22:01
  • @adazebra - I'll whip up a quick example for you when I get home (check back in a couple hours). – DonMag Jan 09 '18 at 22:07
  • Awesome, that would be amazing. – adazebra Jan 09 '18 at 22:14
  • Added a code snippet above that was important. – adazebra Jan 09 '18 at 22:25
  • Are your cells fixed height? Or should they auto-size based on multi-line labels? – DonMag Jan 09 '18 at 23:41
  • Well, hard to say why you're having your issues, without seeing all of your code / xibs / etc. Here is an example, though. Laid-out basically how you have shown... it uses auto-sizing cells (the bottom label has Zero lines, so it will wrap with enough text). https://github.com/DonMag/XIBTableCells – DonMag Jan 10 '18 at 00:10
  • It all looks the same. I can only guess that there's some weird setting in the interface builder that's screwing the whole thing up. – adazebra Jan 10 '18 at 02:20
  • @adazebra - it sounds more like you're missing a constraint (or two). Look very closely. – DonMag Jan 10 '18 at 13:24
  • I used the button that fills in missing constraints. My coding partner just changed the whole thing from interface builder to code. So I guess it's over at this point. – adazebra Jan 11 '18 at 04:58

0 Answers0