旋转UITextView的自定义inputView的问题 [英] Problem with rotating custom inputView for UITextView

查看:94
本文介绍了旋转UITextView的自定义inputView的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个自定义输入视图,该视图将用于替换 UITextView 的标准键盘.如果我将自定义的 UIView 分配为我的 UITextView inputView ,则它在纵向和横向模式下均可正常工作.

I've written a custom input view that is meant to be used to replace the standard keyboard for a UITextView. If I assign my custom UIView as my UITextView's inputView, it works as expected in both portrait and landscape mode.

旋转设备时会出现问题-每当执行此操作时,我的自定义 UIView 都会展开以填充整个屏幕,而不是仅仅遮盖键盘.我对此没有任何自定义的大小调整代码-实际上,我只是将UIView分配为UITextView的inputView属性,然后旋转设备.

The problem occurs when I rotate the device - whenever I do this, my custom UIView expands to fill the entire screen, instead of just covering up the keyboard. I don't have any custom resizing code anywhere for this - I'm literally just assigning the UIView as the UITextView's inputView property and then rotating the device.

当旋转设备时,如何使我的自定义键盘视图仅占据普通键盘占用的空间?

How do I get my custom keyboard view to only occupy the space taken up by the normal keyboard when I rotate the device?

推荐答案

来自Apple文档:

在定义输入视图或输入附件视图的大小和内容时,您具有很大的灵活性.尽管这些视图的高度可以随您的需要而定,但它们的宽度应与系统键盘的宽度相同.如果UIKit遇到自动调整大小掩码中带有UIViewAutoresizingFlexibleHeight值的输入视图,它将更改高度以匹配键盘.

You have a lot of flexibility in defining the size and content of an input view or input accessory view. Although the height of these views can be what you’d like, they should be the same width as the system keyboard. If UIKit encounters an input view with an UIViewAutoresizingFlexibleHeight value in its autoresizing mask, it changes the height to match the keyboard.

查看全文

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