UITableView delegate.tableView(cellForRowAt) is returning -1

I'm working through the itunes U "Developing iOS 10 Apps with Swift" course from Stanford. I was going through the demo in lecture 15 on "More Segues". Here's a link to my code and here's a link to the professor's code. From what I can see in interface builder we both have the same settings for the Expression Editor View Controller, but in this snippet of code in ExpressionEditorViewController.swift:

func heightForRow(at indexPath: IndexPath? = nil) -> CGFloat {
     if let indexPath = indexPath,
          let height = delegate?.tableView?(self, heightForRowAt: indexPath) {
            return height
        } else {
            return rowHeight
        }
    }
}

at like 4 both height and rowHeight are -1 for rows 0, 2, and 3. which are the name text field, eye controls, and mouth controls. As such my popover height is too small for my content. Again, same code in the instructors version works as expected. Any help would be apprecated.

Replies

How and where do you call heightForRow ?

>my popover height is too small for my content.


I ran your sample and don't see the issue...

Hi. Also posted above, here's a link to that file. function viewWillAppear() at line 67 calls

let size = squareUpPreferredSizeStarting(with: tableView.minimumSize(forSection: 0))


function squareUpPreferredSizeStarting() at line 51 calls:

size.height -= tableView.heightForRow(at: blinkingFaceViewIndexPath)