标签:
方法一:
//1 [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
,为了关闭弹出的软键盘要遍历然后调用resignFirstResponder的吧?今天竟然发现一个关键这个view上可能 打开的键盘很简单:[self.view endEditing:YES];
直接ok了。
方法二:
//2
[[self findFirstResponderBeneathView:self] resignFirstResponder];
[[self findFirstResponderBeneathView:self] becomeFirstResponder];//打开键盘
- (UIView*)findFirstResponderBeneathView:(UIView*)view
{
// Search recursively for first responder
for ( UIView *childView in view.subviews ) {
if ( [childView respondsToSelector:@selector(isFirstResponder)] && [childView isFirstResponder] )
return childView;
UIView *result = [self findFirstResponderBeneathView:childView];
if ( result )
return result;
}
return nil;
}
标签:
原文地址:http://www.cnblogs.com/ejllen/p/4329846.html