views:

98

answers:

1

How can I hide the keyboard on ScrollView touch event...

Scenario is like that...

->View ->ScrollView -->Textfield

I want to hide the keyboard on touch of scrollView. I tried to override the class for scrollview,but still i can't do it. Please help me with Code....

+1  A: 

Doing like this will help:

@interface MyClass <UIScrollViewDelegate> {
}

@implementation

- (void)viewDidLoad {
  yourScrollView.delegate = self;
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
  [myTextField resignFirstResponder];
}

If you really want to handle the touch event, then you need to subclass the UIScrollView and override the method:

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view {

}

More about UIScrollView touch

vodkhang
I need to make the keyoboard hide on touch not on dragging the ScrollView...so is there anybody who can help me with this!!!!
Ajay Sharma
But when users drag, they have to touch, is it right
vodkhang
I editted my answer to include the touch event
vodkhang