objective-c - 隐藏在 iOS 9 中的附件栏

标签 objective-c ios9

你好,谁能帮帮我

我想在 ios 9 中隐藏键盘上的附件栏 它在 ios 8 之前一直在工作,但在 ios 9 中我无法隐藏附件栏我厌倦了这段代码但它不起作用

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];
                    }
                }

            }
        }
    }
}

最佳答案

您可以通过从事件文本字段中删除所有辅助栏按钮来隐藏它。

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

关于objective-c - 隐藏在 iOS 9 中的附件栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31317062/

相关文章:

iOS 9 自动布局 : A centered square

ios9 - 在 SFSafariViewController 关闭时,禁用状态栏隐藏动画 [iOS 9]

iphone - 以 Objective C 的方式编写 for 循环

ios - 以编程方式将默认加密 KMS 添加到存储桶

iphone - iPhone 中是否有看起来像 LED 的字体?

ios - Tableview 不能用静态数据平滑滚动

ios - TouchesBegan 不适用于 swift 2.0

ios - 无法将关系对象设置为 CoreData 中的另一个对象

objective-c - 仅适用于我的应用程序的私有(private) cookie?为什么它会影响浏览器的 cookie?

ios - 如何将代码编写的 UI 的旧项目转换为支持 iOS 9 的 Slide Over 和 Split View?