UITextView内部UIScrollView滚动父项作为文本输入 [英] UITextView Inside UIScrollView Scrolling Parent as Text is Entered
问题描述
我有一个 UIScrollView
,其中包含 UITextView
。当文本输入 UITextView
时, UIScrollView
将滚动以确保文本在内容框架中完全可见。我不想要这个。
I have a UIScrollView
that contains a UITextView
. As text is entered into the UITextView
the UIScrollView
will scroll to ensure that the text is entirely visible in the content frame. I don't want this.
我已经在 UIScrollView
上禁用滚动,但是这没有效果。谁知道如何制止这个?可在此处找到示例项目: http://cl.ly/1P1u3y302r3q1f1C063K 。
I've disabled scrolling on the UIScrollView
, however this has no effect. Anyone know how to stop this? A sample project can be found here: http://cl.ly/1P1u3y302r3q1f1C063K.
谢谢!
推荐答案
我遇到类似的问题 UITextView
。似乎 scrollEnabled
属性不会取消自动滚动。我通过覆盖 setContentOffset 解决了它:
方法。
以下 preventScrolling
标志可能会有所帮助:
I had similar issues with UITextView
. It seems scrollEnabled
property does not cancel autoscrolling. I have solved it by overriding setContentOffset:
method.
The following preventScrolling
flag might help:
@interface MyScrollView : UIScrollView
@property (nonatomic, assign) BOOL preventScrolling;
@end
@implementation MyScrollView
@synthesize preventScrolling;
-(void) setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
{
if(!self.preventScrolling) {
[super setContentOffset:contentOffset animated:animated];
}
}
@end
这篇关于UITextView内部UIScrollView滚动父项作为文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!