Search code examples
iphoneuitextfielduitouch

Using UITouch To Drag A UITextField Around The Screen on iPhone


I am developing a sample application, where I have a situation for moving a UITextFields, UILabels etc., across the screen. I am not able to find any resource for implementing this.

I want to implement like this for a UITextField


Solution

  • Since you have an excellent tutorial on dragging already, I will assume your problem is the keyboard that comes up when you try to drag a UITextField instead of a UIView. The solution should be pretty simple: myTextField.userInteractionEnabled = NO; - that should disable user interaction and make it "read only". Perhaps have an edit mode where all text fields get this flag set. If it causes trouble, then add the textField to a UIView and then set the userInteractionEnabled to false. Then you can drag the UIView and it will drag the text field with it.