6

i have use a UIWebview in IOS 5. I try to set contenteditable="true" to make uiwebview editable.

The screenshoot of my app is similar to an image in this link How do you remove the Next and Prev buttons from virtual keyboard in Sencha Touch / Phonegap application,

enter image description here

my problem is i want to remove this prev & next button from the keyboard, but i dont know how. Can some body help me?

thank you

Jonas
  • 121,568
  • 97
  • 310
  • 388
R. Dewi
  • 4,141
  • 9
  • 41
  • 66
  • I found the solution for iOS 8. You can check it here: iOS 8 - Remove Previous/Next/Done UIKeyboard Toolbar inside a UIWebView http://stackoverflow.com/questions/25022089/remove-next-previous-buttons-inputaccessoryview-for-custom-keyboard-in-ios8 – Gaurav Dec 03 '14 at 09:31

4 Answers4

11

This is an old answer and is no longer working on iOS 9. For an updated solution, see my answer here.


It is a gray-area, but certainly possible.

See here: http://ios-blog.co.uk/iphone-development-tutorials/rich-text-editing-a-simple-start-part-1/

Register for notification on keyboard showing:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];

Then:

- (void)keyboardWillShow:(NSNotification *)note {
    [self performSelector:@selector(removeBar) withObject:nil afterDelay:0];
}

- (void)removeBar {
    // Locate non-UIWindow.
    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]) {       
        // iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
        if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
            for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
                if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
                    [subviewWhichIsPossibleFormView removeFromSuperview];
                }
            }
        }
    }
}
Community
  • 1
  • 1
Léo Natan
  • 56,823
  • 9
  • 150
  • 195
3

Remove the empty area.

- (void)removeBar {
    // Locate non-UIWindow.
    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:@"<UIPeripheralHostView"]) {
            for (UIView* peripheralView in [possibleFormView subviews]) {

                // hides the backdrop (iOS 7)
                if ([[peripheralView description] hasPrefix:@"<UIKBInputBackdropView"]) {
                    //skip the keyboard background....hide only the toolbar background
                    if ([peripheralView frame].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
                    UIScrollView *webScroll;
                    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
                        webScroll = [[self webView] scrollView];
                    } else {
                        webScroll = [[[self webView] subviews] lastObject];
                    }
                    CGRect newFrame = webScroll.frame;
                    newFrame.size.height += peripheralView.frame.size.height;
                    webScroll.frame = newFrame;

                    // 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];
                }
            }
        }
    }
}
Yang Peiyong
  • 11,536
  • 2
  • 21
  • 15
1

It's the inputAccessoryView for UIWebBrowserView (inner UIWebView), you can hack it.

Here is an example: https://gist.github.com/bjhomer/2048571

oldman
  • 4,286
  • 2
  • 20
  • 15
1

I found the solution for iOS 8. You can check it here:

-(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;

                }
            }

        }
    }
}
}

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

Hope this helps... This is the level of views in accessory: (UIWebFormAccessory) -> (UIToolbar) -> (UIImageView,UIToolbarButton,UIToolbarButton)

Gaurav
  • 168
  • 12