I have a UITextField
and UIButton
in UIScrollView
.I want to resign keyboard when user touches outside of UITextField
. If i implement UITapGestureRecognizer
then button does not work.any help will be appreciated.thanks in advance
Asked
Active
Viewed 45 times
0

DipakSonara
- 2,598
- 3
- 29
- 34

user3676403
- 25
- 2
-
use this link http://stackoverflow.com/questions/23652079/ios-dismissing-keyboard-uilabel-malfunction/23652253#23652253 – Anbu.Karthik May 27 '14 at 12:35
-
What about touches began delegate ? – Midhun MP May 27 '14 at 12:35
-
It does not get called.. – user3676403 May 27 '14 at 12:36
-
have u tried the above link – Anbu.Karthik May 27 '14 at 12:37
-
If you are working on iOS 7 only, `scrollView` has a property `keyboardDismissMode` that might help. – Gonzo May 27 '14 at 12:45
1 Answers
0
try this..
-(void)viewWillAppear:(BOOL)animated{
UITapGestureRecognizer *tapScroll = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapped)];
tapScroll.cancelsTouchesInView = NO;
[self.scrollView addGestureRecognizer:tapScroll];
}
- (void) tapped {
[self.view endEditing:YES];
}

karthikeyan
- 3,821
- 3
- 22
- 45