Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove top bar of the keyboard in ios 7

Tags:

ios

ios7

In my program I use UIWebView with editable div for the Rich text editor. I need to remove top bar of the keyboard. enter image description here

I used below code - it removes only next/previous buttons I want to remove full top bar.

- (void)removeBar {
    UIWindow *keyboardWindow = nil;
    for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
        if (![[testWindow class] isEqual:[UIWindow class]]) {
            keyboardWindow = testWindow;
            break;
        }
    }

    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];
                }
            }
        }
    }
}
like image 734
Suravi Avatar asked Dec 02 '25 12:12

Suravi


1 Answers

I found the solution for iOS 8. You can check it here: [ iOS 8 - Remove Previous/Next/Done UIKeyboard Toolbar inside a UIWebView][1]

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)

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

                }
            }

        }
    }


}
}
like image 74
Gaurav Avatar answered Dec 05 '25 01:12

Gaurav



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!