Weird - keyboard's still on-screen

I followed the steps on p.256.

But when I ran the app and went to the detail screen, I tapped outside a text field (labels, the date value, empty space), and the keyboard sticks around.

Did anyone else see this?

Make sure your Action connection is in the correct format as the book and that you added listing 12.6:

@IBAction func backgroundTapped(_ sender: UITapGestureRecognizer) {
view.endEditing(true)

@Caps5150 I ran into the same problem. Did you find a solution?

I just realized I dragged the tap gesture recognizer on the date label instead of the background. Now that it’s changed, works great.

2 Likes

I’m stuck here too. I’ve confirmed that my Tap Gesture Recognizer has a Sent Action for backgroundTapped: to go to the Detail View Controller, and DVC has the following for the function:

    @IBAction func backgroundTapped(_ sender: UITapGestureRecognizer) {
        view.endEditing(true)
    }

I know that view.endEditing(true) works because I connected it to viewWillDisappear, so I started debugging and set a breakpoint on the backgroundTapped function–which doesn’t break whenever I click off of a text field.

I am having the same problem and did the same checking. It appears that I can’t leave the text fields’ focus on the simulator–I can’t make a click anywhere except in the text fields.