Believe2014 Believe2014 - 3 months ago 7x
iOS Question

How does the `tap` function get ignored?

Following Apple's Guide to build a MealKeeper app, I was able to create a text field and an image view. After dragging and dropping the

on top of the image view, I added the code to hide the keyboard by making the text field to resign.

When I run this code in simulator, I first click on the text field, the keyboard appears.
Then I click on the image view, the keyboard does not get hide.

How does the
function get ignored?


You need to add the gesture to you imageview, create an IBOutlet to your imageview and add the following to 'viewDidLoad'.

let tapGestureRecognizer = UITapGestureRecognizer(target:self, action:Selector("tap:"))
imageView.userInteractionEnabled = true

Good luck.