Thursday 23 May 2013

UIKit: Simple way to disable gesture recognizer in subview

Sometimes you have gesture recognizer with a view but want to disable it for a subview (e.g. you use the subview as a toolbar). By default you can click "through" the subview as if it does not exist, which can cause confusion. A simple way to disable gesture recognizer in a subview is in UI builder to drag new a gesture recognizer onto the subview, which associates a gesture recognizer with the subview which does nothing when the gesture is recognized.

If you want the child of the subview (e.g. some buttons in this subview) to receive taps, uncheck its "Canceled in view" property.

No comments:

Post a Comment