如何在输入时阻止UITextView向上滚动 [英] How to stop UITextView from scrolling up when entering it
问题描述
我在 UITableViewCell
中包含 UITextView
。最初显示视图时布局是正确的,但是一旦我点击 UITextView
,它会自动向上滚动一下,第一行上的字符的上半部分变为不可见。
I have a UITextView
included in a UITableViewCell
. The layout is correct when the views are initially displayed, but once I click in the UITextView
it automatically scrolls up a bit and the top half of the characters on the first line becomes invisible.
此图片是 UITextView
未激活的时间:
UITextView无效http://gerodt.homeip.net/uitextview-notactive.png
This image is when the UITextView
is not active:
UITextView not active http://gerodt.homeip.net/uitextview-notactive.png
这是当我点击 UITextView
使其激活时:
UITextView有效http://gerodt.homeip.net/uitextview-active.png
And this one is when I clicked in the UITextView
to make it active:
UITextView active http://gerodt.homeip.net/uitextview-active.png
I不要UITextView向上滚动,它应该简单地保持固定。我怎样才能做到这一点?我已经在 Interface Builder
中尝试了几个设置,但到目前为止还没有运气。
I do not the UITextView to scroll up at all, it should simple stay fixed. How can I achieve this? I already tried several settings in Interface Builder
, but no luck so far.
任何建议都表示赞赏。
Gero
推荐答案
根据Apple工程师的说法,这是UITextView的行为方式intent和UITextView适用于高度至少为几行的文本。没有解决方法,使用UITextField代替或将UITextView增加到至少3行高。
This is how UITextView behaves according to Apple's engineer this is intended and UITextView is meant for text that are at least a few lines in height. There is no work around to this, use a UITextField instead or increase your UITextView to at least 3 lines in height.
这篇关于如何在输入时阻止UITextView向上滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!