Remove focus from the textfield

ios, ios4, ios5, ios6, ios7

Solution

You can use this code to remove focus (As said in one of the comment),

[textField1 resignFirstResponder];

Problem

I am doing two operations on a textfield: 1) To move the textfield using pan gesture. 2) To write on the textfield when the user clicks on it. Concern is that I want to perform one operation at a time i.e when the user is writing he cannot scroll and vice versa. Name of UIButton action --- button Name of UIButton outlet --- optionButton ``` - (IBAction)button:(id)sender { if([_optionButton.titleLabel.text isEqualToString:@"SCROLL"]) { NSLog(@"can scroll"); NSLog(@"POINT=============%d ",point); point=0; [_optionButton setTitle:@"WRITE" forState:UIControlStateNormal]; textField1.enabled=NO; } else { NSLog(@"can write"); NSLog(@"POINT=============%d ",point); point=1; [_optionButton setTitle:@"SCROLL" forState:UIControlStateNormal]; textField1.enabled=YES; } } ``` The point variable is controlling the complete operation and is set to 1 at the beginning.This means that the user can write in the beginning and if he want to write he has to press the button. The problem that I am facing is that by using "textField1.enabled=NO" I am not able to scroll the textfield. Is there any function using which I can remove the focus from the textfield but can scroll it.

Original source