2

A UIScrollView consists of various UITextFields like name, phone, etc. Of course, When i click on a textField, keyboard appears.

I want to know how to make the keyboard disappear once the user starts scrolling. Thanks for any Help!

motox
  • 759
  • 10
  • 17

3 Answers3

5

You can implement UIScrollViewDelegate and once the user starts to scroll using scrollViewDidScroll method, you can make the keyboard go hidden. Try like this:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
 [self.view endEditing:YES];
}      

Make sure you set the delegate for your UIScrollView.

GenieWanted
  • 4,473
  • 4
  • 24
  • 35
2

Try following code:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
         [self.textField resignFirstResponder];
    }
Vlad Z.
  • 3,401
  • 3
  • 32
  • 60
0

Use this to hide keyboard.

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
      [self.view endEditing:YES];//hide keyboard
}
Ayaz
  • 1,398
  • 15
  • 29