隐藏在ios 9中的附件栏 [英] accessory bar hiding in ios 9

查看:74
本文介绍了隐藏在ios 9中的附件栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我吗

我想在iOS 9中隐藏键盘上的附件栏 直到ios 8都可以正常工作,但是在ios 9中我无法隐藏附件栏,我很讨厌这段代码,但是无法正常工作

i want to hide the accessory bar from keyboard in ios 9 its working find till ios 8 but in ios 9 i am not able to hide the accessory bar i tired this code but its not working

for (UIView *possibleFormView in [keyboardWindow subviews]) {

    if([[possibleFormView description] hasPrefix:@"<UIInputSetContainerView"])
    {
        for(UIView *view1 in possibleFormView.subviews)
        {
            if([[view1 description] hasPrefix:@"<UIInputSetHostView"])
            {
                for (UIView *peripheralView_sub in view1.subviews) {
                    //Hides the backdrop (iOS 8)
                    if ([[peripheralView_sub description] hasPrefix:@"<UIKBInputBackdropView"] ) {
                        [[peripheralView_sub layer] setOpacity:0.0];
                    }
                    if([[peripheralView_sub description] hasPrefix:@"<<_UIRemoteKeyboardPlaceholderView"])
                    {
                        CGRect newRect= peripheralView_sub.frame;
                        newRect.origin.y=44;
                        newRect.size.height=398-44;
                        peripheralView_sub.frame=newRect;

                        peripheralView_sub.clipsToBounds=false;

                        for(UIView *remoteKeyboardView in peripheralView_sub.subviews)
                        {
                            NSLog(@"Remote Key View %@",remoteKeyboardView);
                        }
                    }
                    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;
                        [peripheralView_sub removeFromSuperview];
                    }
                }

            }
        }
    }
}

推荐答案

您可以通过从活动文本字段中删除所有助手栏按钮来隐藏它.

You can hide it by removing all assistant bar buttons from the active textfield.

UITextField *textField = ...
if ([textField respondsToSelector:@selector(inputAssistantItem)]) {
    UITextInputAssistantItem *inputAssistantItem = [textField inputAssistantItem];
    inputAssistantItem.leadingBarButtonGroups = @[];
    inputAssistantItem.trailingBarButtonGroups = @[];
}

这篇关于隐藏在ios 9中的附件栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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