UIScrollView中的UITextView不可滚动 [英] UITextView in UIScrollView is not scrollable
问题描述
我的UIScrollView
中有一个UITextView
. Scrollview
包含图像并水平滚动. Textview
被添加为子视图并包含一些文本.有时文本很长,所以我希望textview是可滚动的.这是我的工作:
I have a UITextView
in my UIScrollView
. The Scrollview
contains images and scrolls horizontally. The Textview
is added as a subview and contains some text. Sometimes the text is quite long, so I want the textview to be scrollable. Here is what I do:
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(260, 490, 280, 86)];
[textView setBackgroundColor:[UIColor colorWithRed:63.0f/255.0f green:154/255.0f blue:201/255.0f alpha:1.0f]];
[textView setTextColor:[UIColor whiteColor]];
[textView setFont:[UIFont fontWithName:@"Helvetica" size:14.0]];
[textView setScrollEnabled:YES];
[textView setUserInteractionEnabled:YES];
[textView setContentSize:CGSizeMake(280, 400)];
问题是,我无法滚动.
滚动视图是否有可能吞噬我的触摸?什么是干净的解决方案?
Is it possible, that the scrollview eats my touches? What would be a clean solution for this?
推荐答案
UIScrollViews具有名为delaysContentTouches
的bolean属性.默认情况下,它设置为YES
-它告诉滚动视图延迟将触摸事件传递到其子视图.
UIScrollViews have a bolean property called delaysContentTouches
. By default, this is set to YES
- it tells the scroll view to delay passing on touch events to its subviews.
这就是为什么当前您的文本视图不滚动的原因.如果将delaysContentTouches
设置为NO
,则希望您现在可以使用文本视图.
This is why currently your text view doesn't scroll. If you set delaysContentTouches
to NO
you will hopefully find your text view now working.
这篇关于UIScrollView中的UITextView不可滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!