I'm attempting to use the UITapGestureRecognizer object that can be found in Interface Builder. I've dragged a single "UITapGestureRecognizer" from the object library to a single view xib. I then create an IBAction method from this tap gesture, for a simple test, I'm just printing an "NSLog" message to the console once there is a tap on the view. I've run this, and the tap method isn't being called. I right click the view in IB and I noticed that there is a warning "!" on the view's "Outlet Collections" I see:
Outlet Collections
gestureRecognizers - Tap Gesture Recognizer (!)
The warning states: UIView does not have an outlet collection named gestureRecognizers.
What do I need to do to remedy this?
Mr.Anonymous solution is correct. No need to implement the delegate in the view controller or set it. However, you should check that User interaction enabled is checked (in the properties window on the right), especially if you are attaching the recognizer to a label.
I think you have not wired the UITapGestureRecognizer
properly to your code.
When you drop a UITapGestureRecognizer
on your xib Xcode
automatically makes the necessary referencing outlet connections.
You only need to create an IBAction
method in your code and then wire it to the selector of the UITapGestureRecognizer
placed in xib
.
I have attached screenshots for ur reference.
Hope this helps!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With