如何使InputAccessoryView出现在UITabBarViewController的选项卡上方? [英] How to make InputAccessoryView appear above UITabBarViewController's tabs?

查看:110
本文介绍了如何使InputAccessoryView出现在UITabBarViewController的选项卡上方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义视图,我将其用作tableViewControllerinputAccessoryView.

I have a custom view that I am using as inputAccessoryView for my tableViewController.

tableViewControlleris.

我设法使自定义视图正确显示为inputAccessoryView,显示在底部,并在聚焦时随键盘向上移动.

I managed to make the custom view appear correctly as the inputAccessoryView, appearing at the bottom, and when focused it goes up with the keyboard.

我的问题是,它隐藏了我的tabBar,我进行了搜索,但除了2岁未解决的问题外,找不到任何东西. 我希望我的视图显示在tabBar上方,类似于在播放歌曲时的音乐应用,歌曲和播放按钮以及下一个按钮显示在tabBar上方而不隐藏它.

My problem is that it's hiding my tabBar, I searched but couldn't find anything except for a 2years old unanswered question. I want my view to appear above the tabBar, similar to the music app when having a song playing, the song and the play button and the next button appear above the tabBar not hiding it.

使用Swift 4.2,Xcode 10.1,iOS 11目标,在iOS 12.1和12.1.1上进行测试

using swift 4.2, Xcode 10.1, iOS 11 target, testing on iOS 12.1 and 12.1.1

推荐答案

我已经能够实现这种效果,并制作了一个名为

I have been able to achieve this effect and made a framework called AMKeyboardFrameTracker to do just that

但是首先您需要了解inputAccessoryView的工作方式

but first you need to understand how the inputAccessoryView work

inputAccessoryView附加到另一个名为UITextEffectsWindow的窗口,该窗口显示在主应用程序窗口的顶部

inputAccessoryView is attached to another window called UITextEffectsWindow this window shows on top of your main app window

使用inputAccessoryView的主要功能是与任何UIScrollView的交互式键盘消除效果,因为通常您无法从本机键盘通知回调中获取键盘框架

The main feature of using inputAccessoryView is the interactive keyboard dismissal effect with any UIScrollView because normally you can't get the keyboard frame from the native keyboard notifications callbacks

但是使用 AMKeyboardFrameTracker ,我已经能够从inputAccessoryView's superview通过观察它的帧变化,因此它仍在使用inputAccessoryView,但具有没有用户交互的空视图

But with AMKeyboardFrameTracker I've been able to get the keyboard frame from the inputAccessoryView's superview by observing it's frame changes, so it's still using inputAccessoryView but with an empty view that has no user interaction

Github存储库中有一个示例,您可以下载并试用

There is an Example in the Github repo you can download it and try it out

注意 在示例应用程序中,我使用普通的ViewController而不是TableViewController,如果您想使用TableViewController,仍然可以通过将CustomView添加到navigationController's view

Note in the example app I am using a normal ViewController instead of a TableViewController if you'd like to use a TableViewController you can still achieve this by adding your CustomView to the navigationController's view

这篇关于如何使InputAccessoryView出现在UITabBarViewController的选项卡上方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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