iosuitextfieldtouches

Disable touches but not all user interaction on UITextField


I have a UITextField but I want to be in control of when it is focussed and when it is unfocussed.

In order to achieve this I need to be able to block touch events on that text field. I know I could just put a button in front of it and manually do it, but I wanted to know if there was any way to just disable touches on the element.

Many thanks.


Solution

  • There does not appear to be a way to block touches with a property of UITextField. I solved this problem by placing a UIView over the text field to block the touches. I set the UIView to "Clear Color" using the attributes inspector. Works great for my application.