I'm developing PhoneGap application for iOS and I need to get rid of new iOS 9 shortcut bar. Now I'm doing the following in the - (void)viewDidLoad
method
if ([self.webView respondsToSelector:@selector(inputAssistantItem)]) { UITextInputAssistantItem *inputAssistantItem = [self.webView inputAssistantItem]; inputAssistantItem.leadingBarButtonGroups = @[]; inputAssistantItem.trailingBarButtonGroups = @[]; }
This hides undo/redo and copy/paste buttons but shortcut bar still presented on keyboard and has navigation buttons on it.
How can I get rid of shortcut bar completely.
Thanks for your help!
*** UPDATE 1 ***
My full working code is below. Hope this can help someone (thanks to @Clement reply)
#import <objc/runtime.h> - (void) hideKeyboardShortcutBar: (UIView *)view { for (UIView *sub in view.subviews) { [self hideKeyboardShortcutBar:sub]; if ([NSStringFromClass([sub class]) isEqualToString:@"UIWebBrowserView"]) { Method method = class_getInstanceMethod(sub.class, @selector(inputAccessoryView)); IMP newImp = imp_implementationWithBlock(^(id _s) { if ([sub respondsToSelector:@selector(inputAssistantItem)]) { UITextInputAssistantItem *inputAssistantItem = [sub inputAssistantItem]; inputAssistantItem.leadingBarButtonGroups = @[]; inputAssistantItem.trailingBarButtonGroups = @[]; } return nil; }); method_setImplementation(method, newImp); } } } - (void)viewDidLoad { [super viewDidLoad]; [self hideKeyboardShortcutBar:self.webView]; }
This trick will hide undo/redo and navigation buttons. But auto-prediction text still will be shown on keyboard. To hide shortcut bar completely add html attributes to your input element
<input autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
P.S My app is on the review now. Still don't know if Apple will approve this.
*** UPDATE 2 ***
My app was approved by Apple