hiding keyboard ios


This question already has an answer here:


If you want to hide the keyboard when you tap a button and you have more than one UITextFields in your view, then you should use:

[self.view endEditing:YES];

Tap anywhere on the view, and the keyboard will disappear.

Try this:

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
     [[self view] endEditing:YES];

You can also iterate through an array of views (such as your UIView's subviews) and manually resign the keyboard, this is good if you dont want to resign on ALL the subviews within your parent UIView.

- (void)viewDidLoad
    self.view.userInteractionEnabled = TRUE;
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    //Iterate through your subviews, or some other custom array of views
    for (UIView *view in self.view.subviews)
        [view resignFirstResponder];

You can try UITouch method, and in this set your text field object and call resignFirstResponder when ever you touch on the screen the keyboard will resign, I hope this will work for you.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    [currentSelectedTextField resignFirstResponder];

Need Your Help

LINQ - is SkipWhile broken?

c# linq linq-to-objects

I'm a bit surprised to find the results of the following code, where I simply want to remove all 3s from a sequence of ints:

How Do I Take a Screen Shot of a UIView?

ios objective-c uiview screenshot

I am wondering how my iPhone app can take a screen shot of a specific UIView as a UIImage.