Search code examples
iosswiftuitableviewuinavigationcontroller

Navigating from UITableView to another ViewController and then going back to the TableViewController causes some elements to disappear


I have a strange issue in my notes app. I have a ViewController that is a UITableView delegate and datasource (I do not use UITableViewController) The table view is a list of notes. Clicking one will open the editor view controller for the selected note.

When I click a cell, then click the "Back" button to go back to the table view, some elements of the table view UI appear missing.

Here is a before and after screenshot of the table view:

before and after

I am using Realm mobile database to store the data for the notes.

When I debug I see that data is actually populated in the cells, it just does not appear on the screen.

I tried removing the app and reinstalling it

I tried deleting the storyboard and rebuilding everything from scratch

I check the cellForRowAt indexPath and made sure the data is being populated.

Update - code for cellForRowAt indexPath::

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: NoteListCell.identifier, for: indexPath) as! NoteListCell

    let object = results[indexPath.row]
    cell.configureCellWith(note: object)
    return cell
}

I even tried adding a background color to the labels that disappear to see if they are still there or is it just the text that's missing (it's not the text, the entire label was gone).

I don't have anything special in my code for handling the tableview data or navigating between view controllers. I have nothing in my viewWillAppear and viewWillDisappear methods for both VCs that causes this (i tired removing everything from those methods but the issue remains)

Anyone has any idea on what else I can check?


Solution

  • So I still don't know why this was happening, but I installed Xcode 9 beta and ran the project from there (I was using 8.3.3 before) and the problem disappeared. It's possible that reinstalling 8.3.3 would also solve the issue.