Repository: cordova-plugins Updated Branches: refs/heads/master 585a8c8fa -> 2c1c0a513
Updated Plugin to iOS 8 (closes #16) Apple changed the way Keyboard Views are created and plugins was crashing the App; Signed-off-by: Shazron Abdullah <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/2c1c0a51 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/2c1c0a51 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/2c1c0a51 Branch: refs/heads/master Commit: 2c1c0a5135bf7385688b08c47ef0c9a4529fd5e9 Parents: 585a8c8 Author: fmgasparino <[email protected]> Authored: Wed Nov 5 12:31:16 2014 -0800 Committer: Shazron Abdullah <[email protected]> Committed: Fri Nov 21 13:46:25 2014 -0800 ---------------------------------------------------------------------- keyboard/src/ios/CDVKeyboard.m | 99 ++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/2c1c0a51/keyboard/src/ios/CDVKeyboard.m ---------------------------------------------------------------------- diff --git a/keyboard/src/ios/CDVKeyboard.m b/keyboard/src/ios/CDVKeyboard.m index 17bb3e5..cdde80e 100644 --- a/keyboard/src/ios/CDVKeyboard.m +++ b/keyboard/src/ios/CDVKeyboard.m @@ -203,46 +203,79 @@ // ////////////////////////////////////////////////// +- (NSArray*)getKeyboardViews:(UIView*)viewToSearch{ + NSArray *subViews; + + for (UIView *possibleFormView in viewToSearch.subviews) { + if ([[possibleFormView description] hasPrefix: self.getKeyboardFirstLevelIdentifier]) { + if(IsAtLeastiOSVersion(@"8.0")){ + for (UIView* subView in possibleFormView.subviews) { + return subView.subviews; + } + }else{ + return possibleFormView.subviews; + } + } + + } + return subViews; +} + +- (NSString*)getKeyboardFirstLevelIdentifier{ + if(!IsAtLeastiOSVersion(@"8.0")){ + return @"<UIPeripheralHostView"; + }else{ + return @"<UIInputSetContainerView"; + } +} + + - (void)formAccessoryBarKeyboardWillShow:(NSNotification*)notif { if (!_hideFormAccessoryBar) { return; } - NSArray* windows = [[UIApplication sharedApplication] windows]; - - for (UIWindow* window in windows) { - for (UIView* view in window.subviews) { - if ([[view description] hasPrefix:@"<UIPeripheralHostView"]) { - for (UIView* peripheralView in view.subviews) { - // hides the backdrop (iOS 7) - if ([[peripheralView description] hasPrefix:@"<UIKBInputBackdropView"]) { - // check that this backdrop is for the accessory bar (at the top), - // sparing the backdrop behind the main keyboard - CGRect rect = peripheralView.frame; - if (rect.origin.y == 0) { - [[peripheralView layer] setOpacity:0.0]; - } - } - - // hides the accessory bar - if ([[peripheralView description] hasPrefix:@"<UIWebFormAccessory"]) { - // remove the extra scroll space for the form accessory bar - CGRect newFrame = self.webView.scrollView.frame; - newFrame.size.height += peripheralView.frame.size.height; - self.webView.scrollView.frame = newFrame; - - _accessoryBarHeight = peripheralView.frame.size.height; - - // remove the form accessory bar - [peripheralView removeFromSuperview]; - } - // hides the thin grey line used to adorn the bar (iOS 6) - if ([[peripheralView description] hasPrefix:@"<UIImageView"]) { - [[peripheralView layer] setOpacity:0.0]; - } - } + UIWindow *keyboardWindow = nil; + for (UIWindow *windows in [[UIApplication sharedApplication] windows]) { + if (![[windows class] isEqual:[UIWindow class]]) { + keyboardWindow = windows; + break; + } + } + + for (UIView* peripheralView in [self getKeyboardViews:keyboardWindow]) { + + // hides the backdrop (iOS 7) + if ([[peripheralView description] hasPrefix:@"<UIKBInputBackdropView"]) { + // check that this backdrop is for the accessory bar (at the top), + // sparing the backdrop behind the main keyboard + CGRect rect = peripheralView.frame; + if (rect.origin.y == 0) { + [[peripheralView layer] setOpacity:0.0]; + } + } + + // hides the accessory bar + if ([[peripheralView description] hasPrefix:@"<UIWebFormAccessory"]) { + //remove the extra scroll space for the form accessory bar + CGRect newFrame = self.webView.scrollView.frame; + newFrame.size.height += peripheralView.frame.size.height; + self.webView.scrollView.frame = newFrame; + + _accessoryBarHeight = peripheralView.frame.size.height; + + // remove the form accessory bar + if(IsAtLeastiOSVersion(@"8.0")){ + [[peripheralView layer] setOpacity:0.0]; + }else{ + [peripheralView removeFromSuperview]; } + + } + // hides the thin grey line used to adorn the bar (iOS 6) + if ([[peripheralView description] hasPrefix:@"<UIImageView"]) { + [[peripheralView layer] setOpacity:0.0]; } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
