如何在输入时阻止 UITextView 向上滚动 [英] How to stop UITextView from scrolling up when entering it
问题描述
我有一个 UITextView
包含在 UITableViewCell
中.最初显示视图时布局是正确的,但是一旦我单击 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
我根本不使用 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.
感谢任何建议.
格罗
推荐答案
根据 Apple 的工程师的说法,这是 UITextView 的行为方式,这是预期的,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屋!