在iOS8 WebView中删除自定义键盘的下一个/上一个按钮(inputAccessoryView) [英] Remove Next / Previous buttons (inputAccessoryView) for Custom Keyboard in iOS8 WebView

查看:597
本文介绍了在iOS8 WebView中删除自定义键盘的下一个/上一个按钮(inputAccessoryView)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请耐心等待,我在互联网上搜索了很多,因为它是一个新的API而无法找到解决方案。

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

我正在尝试创建一个适用于iOS 8的自定义键盘。除了WebView外,它的工作方式非常好!
它有前一个下一个按钮,它位于 inputAccessoryView 中。我知道它是webview的只读属性,但由于iOS 8允许用户使用自定义键盘,我认为这个视图应该可以在某处编辑。有没有人遇到同样的问题?任何帮助将不胜感激。

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.

推荐答案

您可以尝试改进这一点。尝试在你的UIKeyboardDidShowNotification事件处理程序中调用此函数。

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)

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






移除或缩放到零高度附件栏将导致黑色区域。你可以玩主视图的框架或边界。或者如果您只是想摆脱按钮,只需尝试在UITool按钮上设置0不透明,工具按钮在uitoolbar视图中

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

这篇关于在iOS8 WebView中删除自定义键盘的下一个/上一个按钮(inputAccessoryView)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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