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

Remove Next / Previous buttons (inputAccessoryView) for Custom Keyboard in iOS8 WebView(删除 iOS8 WebView 中自定义键盘的下一个/上一个按钮 (inputAccessoryView))
本文介绍了删除 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) ->(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

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)