programming
Objective-C / 입력 필드 외의 장소에 터치할 경우 키보드 감춤
artfrige
2015. 5. 7. 20:45
UIGestureRecognizer 등의 방법을 쓸 수도 있으나
일단 ViewController에 아래 메소드를 입력하면 됨.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
for (UIView * youtxtfl in self.view.subviews){
if ([youtxtfl isKindOfClass:[UITextField class]] && [youtxtfl isFirstResponder]) {
[youtxtfl resignFirstResponder];
}
}
}