如何在文本上面移动UITextView校正建议 [英] How to move UITextView correction suggestion above text

查看:135
本文介绍了如何在文本上面移动UITextView校正建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用UITextView大致复制键盘上方的SMS文本框。我使用一个UITextView而不是一个字段,以便它可以扩展与多行。

I'm using a UITextView to roughly replicate the SMS text box above the keyboard. I'm using a UITextView instead of a field so that it can expand with multiple lines.

问题是,在我的UITextView,校正建议弹出 下面的文本,导致它们被键盘部分遮掩。

The problem is that, in my UITextView, the correction suggestions pop up below the text, causing them to be partially obscured by the keyboard.

在短信应用中,建议弹出在文本上方。该展示位置似乎不是UITextView或UITextInputTraits的属性。

In the SMS app, the suggestions pop up above the text. The placement does not appear to be a property of UITextView, or UITextInputTraits.

任何想法如何复制此行为?感谢!

Any idea how to replicate this behavior? Thanks!

推荐答案

问题是,键盘是作为一个单独的UIWindow实现的,而不是作为主UIWindow中的视图,所以布局与它是棘手的。下面是一些正确方向的指针:

The problem is that the Keyboard is implemented as a separate UIWindow, rather than as a view within the main UIWindow, so layout with it is tricky. Here are some pointers in the right direction:


  • 通过应用程序的 -windows 属性来查找私有 UITextEffectsWindow 窗口并确定其框架。这是键盘

  • 通过TextView的子视图查找私人 UIAutocorrectInlinePrompt 视图。这是自动更正气泡。

  • 将该子视图移动到单独的包装器视图(添加到TextView中),然后移动该包装器视图,使其位于上述键盘窗口的上方。

  • Hunt through the application's -windows property to find the private UITextEffectsWindow window and figure out its frame. This is the keyboard
  • Hunt through the TextView's subviews to find the private UIAutocorrectInlinePrompt view. This is the autocorrect bubble.
  • Move that subview into a separate wrapper view (added to the TextView) and then move that wrapper view so it's above the above-mentioned keyboard window.

您会注意到上面提到的两个私人。这包含所有相关的警告。我不知道为什么苹果已经允许这个问题持续,甚至他们的应用程序不得不解决它。

You'll notice two mentions of "private" above. That carries all the relevant caveats. I have no idea why Apple has allowed the problem to persist when even their apps have had to work around it.

这篇关于如何在文本上面移动UITextView校正建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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