Remove Next / Previous buttons (inputAccessoryView) for Custom Keyboard in iOS8 WebView
Asked Answered
G

2

7

Please bear with me, I searched a lot over the internet and I couldn't find a solution since it's a new API.

I am trying to create a custom keyboard for iOS 8. It works perfectly fine except in WebView! It has previous-next button, which are in inputAccessoryView. I know it's read-only property for webview but since iOS 8 allows the users to have custom keyboard I assume this view should be editable somewhere. Has anybody run into the same issue? Any help would be appreciated.

Gigantism answered 29/7, 2014 at 18:6 Comment(0)
B
7

You may try and improve this. try call this function inside Your UIKeyboardDidShowNotification event handler.

-(void) removeKeyboard {
    UIWindow *keyboardWindow = nil;
    for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
        if (![[testWindow class] isEqual : [UIWindow class]]) {
            keyboardWindow = testWindow;
            break;
        }
    }
    // Locate UIWebFormView.
    for (UIView *possibleFormView in [keyboardWindow subviews]) {

        if ([[possibleFormView description] hasPrefix : @"<UIInputSetContainerView"]) {
            for (UIView* peripheralView in possibleFormView.subviews) {

                for (UIView* peripheralView_sub in peripheralView.subviews) {


                    // hides the backdrop (iOS 8)
                    if ([[peripheralView_sub description] hasPrefix : @"<UIKBInputBackdropView"] && peripheralView_sub.frame.size.height == 44) {
                        [[peripheralView_sub layer] setOpacity : 0.0];

                    }
                    // hides the accessory bar
                    if ([[peripheralView_sub description] hasPrefix : @"<UIWebFormAccessory"]) {


                        for (UIView* UIInputViewContent_sub in peripheralView_sub.subviews) {

                            CGRect frame1 = UIInputViewContent_sub.frame;
                            frame1.size.height = 0;
                            peripheralView_sub.frame = frame1;
                            UIInputViewContent_sub.frame = frame1;
                            [[peripheralView_sub layer] setOpacity : 0.0];

                        }

                        CGRect viewBounds = peripheralView_sub.frame;
                        viewBounds.size.height = 0;
                        peripheralView_sub.frame = viewBounds;

                    }
                }

            }
        }
    }

}

Hope this helps...

This is the level of views in accessory:

(UIWebFormAccessory) -> (UIToolbar) -> (UIImageView,UIToolbarButton,UIToolbarButton)



Removing or scaling to zero height the accessory bar will cause black area. You can play around the mainview's frame or bounds. or if You just want to get rid of the buttons, just try to have a 0 opacity on the UIToolbutton , the toolbutton is inside uitoolbar view

Bromberg answered 25/9, 2014 at 7:6 Comment(6)
Thanks @Sel It's a hacky and unreliable way to remove it, I'm looking for an standard API to remove this view.Gigantism
@Sel i also want to remove the predictive text bar from the keyboard please help if you have any code how to do that.Sappanwood
@Gigantism have got any api foe that please help i also have the same issueSappanwood
@ManjitSingh Not yet :(Gigantism
@Gigantism is there any way to remove the predictive text bar from the keyboard programmatically in c++.Sappanwood
@ManjitSingh Yes, look at this link. Please vote up both question and answer :) #25041656Gigantism
B
2

Use this , it works like a charm and it is much cleaner than the other solutions. It's hacking with the inputAccessoryView for UIWebBrowserView (inner UIWebView).

Good luck with coding!

Banville answered 17/12, 2014 at 11:41 Comment(3)
Thanks @ingaham, but I'm looking for a standard way to remove this view. Your solution is not reliable because it's hacking private API.Gigantism
Unfortunately there is no 'standard way' to remove it, the iOS has no API for this. The solution provided above is also a hack (UIInputSetContainerView or UIKBInputBackdropView are even private classes).Banville
That's very disappointing, they offered custom keyboard in iOS 8, they should give this ability to hide this ugly view.Gigantism

© 2022 - 2024 — McMap. All rights reserved.