how to remove prev next button from virtual keyboard IOS

后端 未结 4 514
独厮守ぢ
独厮守ぢ 2020-12-09 01:03

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

相关标签:
4条回答
  • 2020-12-09 01:07

    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];
                    }
                }
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-09 01:14

    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];
                    }
                }
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-09 01:18

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

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

    0 讨论(0)
  • 2020-12-09 01:31

    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)

    0 讨论(0)
提交回复
热议问题