We could find the keyboard view When keyboardWillShow
-(void) viewDidLoad{
[[NSNotificationCenter defaultCenter] addObserver:
self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
}
- (void)keyboardWillShow:(NSNotification *)note
{
NSDictionary *info = [note userInfo];
NSValue *keyBounds = [info objectForKey:UIKeyboardBoundsUserInfoKey];
CGRect bndKey;
[keyBounds getValue:&bndKey];
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i = 0; i < [tempWindow.subviews count]; i++)
{
//Get a reference of the current view
keyboard = [tempWindow.subviews objectAtIndex:i];
//Check to see if the description of the view we have referenced is "UIKeyboard" if so then we found
//the keyboard view that we were looking for
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
{
[keyboard removefromesuperview];
break;
}
}
}
Hide or remove keyboard When Click UITextField(UITextView)
最新推荐文章于 2024-10-24 19:54:04 发布