删除 ios7 上的键盘窗体工具栏会留下模糊 [英] Remove Keyboard Form toolbar on ios7 leaves a blur behind

查看:21
本文介绍了删除 ios7 上的键盘窗体工具栏会留下模糊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以移除工具栏,但我留下的宽度比工具栏的高度要模糊.

I can remove the toolbar but I am left width a blur of the height the toolbar was.

知道如何删除它吗?

下面的代码是函数.这很直接.我使用 phonegap 在 webview 中使用它.

The code below is the function. It's pretty straight forward. I use this in a webview using phonegap.

-(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) {

            // remove the border above the toolbar in iOS 6
            [
                [possibleFormView layer] setMasksToBounds: YES];

            for (UIView * subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
                if ([
                    [subviewWhichIsPossibleFormView description] rangeOfString: @"UIWebFormAccessory"].location != NSNotFound) {
                    [subviewWhichIsPossibleFormView removeFromSuperview];

                    // http://stackoverflow.com/questions/10746998/phonegap-completely-removing-the-black-bar-from-the-iphone-keyboard/10796550#10796550
                    UIScrollView * webScroll;
                    if ([
                        [
                            [UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
                        webScroll = [
                            [self webView] scrollView];
                    } else {
                        webScroll = [
                            [
                                [self webView] subviews] lastObject];
                    }

                    CGRect newFrame = [webScroll frame];

                    float accessoryHeight = [subviewWhichIsPossibleFormView frame].size.height;
                    newFrame.size.height += accessoryHeight;

                    [subviewWhichIsPossibleFormView removeFromSuperview];
                    [webScroll setFrame: newFrame];
                }
            }
        }
    }
}

如果您遇到此问题,请务必前往 https://bugreport.apple.com 并复制 rdar://9844216

If you hit this problem, make sure to head over to https://bugreport.apple.com and duplicate rdar://9844216

推荐答案

- (void)removeKeyboardTopBar {
// 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) {

            // HERE!! hides the backdrop (iOS 7)
            if ([[peripheralView description] hasPrefix:@"<UIKBInputBackdropView"]) {
                [[peripheralView layer] setOpacity:0.0];
            }
            // hides the accessory bar
            if ([[peripheralView description] hasPrefix:@"<UIWebFormAccessory"]) {
                // remove the extra scroll space for the form accessory bar
                CGRect newFrame = diaryEditorView.scrollView.frame;
                newFrame.size.height += peripheralView.frame.size.height;
                diaryEditorView.scrollView.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];
            }
        }
    }
}

}

这篇关于删除 ios7 上的键盘窗体工具栏会留下模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆