Skip to content

Instantly share code, notes, and snippets.

@HackingGate
Created May 9, 2015 04:09
Show Gist options
  • Save HackingGate/d79c36f044f8ea0e802e to your computer and use it in GitHub Desktop.
Save HackingGate/d79c36f044f8ea0e802e to your computer and use it in GitHub Desktop.
Keyboard dismiss when scrollView drag.
@interface ScrollView <UIScrollViewDelegate,UITextFieldDelegate> {
UITextField *_currentTF;
}
@implementation
- (void)viewDidLoad {
yourScrollView.delegate = self;
yourTextField.delegate = self;
}
#pragma mark UIScrollViewDelegate
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[_currentTF resignFirstResponder];
}
#pragma mark UITextFieldDelegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
_currentTF = textField;
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment