用户登录
用户注册

分享至

删除 iOS8 WebView 中自定义键盘的下一个/上一个按钮 (inputAccessoryView)

  • 作者: 奭麚
  • 来源: 51数据库
  • 2023-02-09

问题描述

请多多包涵,我在互联网上搜索了很多,但我找不到解决方案,因为它是一个新的 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) ->(UI工具栏)->(UIImageView,UIToolbarButton,UIToolbarButton)

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

移除或缩放到零高度的辅助栏将导致黑色区域.您可以围绕主视图的框架或边界进行播放.或者如果您只是想摆脱按钮,只需尝试在 UIToolbutton 上设置 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

软件
前端设计
程序设计
Java相关