Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardAppearanceDefault object:nil];
- - (void)keyboardWasHidden:(NSNotification*)aNotification
- {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardAppearanceDefault object:nil];
- [((PhoneGapDelegate*)[[UIApplication sharedApplication] delegate]).webView stringByEvaluatingJavaScriptFromString:@"document.getElementById(signal.currentPage).scrollIntoView();"];
- }
- - (void)keyboardWasShown:(NSNotification*)aNotification
- {
- UIWindow* tempWindow;
- //Because we cant get access to the UIKeyboard throught the SDK we will just use UIView.
- //UIKeyboard is a subclass of UIView anyways
- UIView* keyboard;
- //Check each window in our application
- for(int c = 0; c < [[[UIApplication sharedApplication] windows] count]; c ++)
- {
- //Get a reference of the current window
- tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c];
- //Get a reference of the current view
- for(int i = 0; i < [tempWindow.subviews count]; i++)
- {
- keyboard = [tempWindow.subviews objectAtIndex:i];
- if([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES)
- {
- keyboard.hidden = YES;
- UIView* keyboardLayer;
- for(int n = 0; n < [keyboard.subviews count]; n++)
- {
- keyboardLayer = [keyboard.subviews objectAtIndex:n];
- NSLog(@" keyboardLayer ::: %@ " ,keyboardLayer);
- if([[keyboardLayer description] hasPrefix:@"<UIWebFormAccessory"] == YES)
- {
- [keyboardLayer removeFromSuperview ];
- }
- }
- keyboard.hidden = NO;
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardAppearanceDefault object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasHidden:) name:UIKeyboardDidHideNotification object:nil];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement