我有一个名为UITextView
的{{1}},我将其作为子视图添加到descriptionText
。它本身是viewDescription
的子视图:
sliderView
由于某种原因,sliderView -> viewDescription -> descriptionText
不会滚动。但是,如果我将其作为子视图添加到descriptionText
,它会滚动...
这就是我创建sliderView
:
UITextView
请注意,我已设置:
_descriptionText = [[UITextView alloc] initWithFrame:CGRectMake(10, 30, 220, 100)];
_descriptionText.text = @"Some long text here...";
_descriptionText.backgroundColor = [UIColor clearColor];
_descriptionText.textAlignment = UITextAlignmentLeft;
_descriptionText.textColor = [UIColor whiteColor];
_descriptionText.font = [UIFont boldSystemFontOfSize:11];
_descriptionText.editable = NO;
我怎样才能让它发挥作用?
编辑1: 我也尝试了所有这些,但没有任何改进:
_viewDescription.userInteractionEnabled = YES;
编辑2: 这是_viewDescription:
[_descriptionText setContentSize:CGSizeMake(500, 500)];
[_descriptionText setContentOffset:CGPointMake(200, 200)];
[_descriptionText setOpaque:TRUE];
[_descriptionText setEditable:NO];
[_descriptionText setShowsVerticalScrollIndicator:YES];
[_descriptionText setScrollEnabled:YES];
[_descriptionText setUserInteractionEnabled:YES];
这是自定义sliderView:
_viewDescription = [[UIView alloc] initWithFrame:CGRectMake( self.frame.size.width + 20, 110, 230, 140)];
请注意,PTSliderDimension是一个继承自UIView的自定义类。
答案 0 :(得分:1)
添加
_descriptionText.scrollEnabled = YES;
答案 1 :(得分:1)
viewDescription
有哪些框架?可能它比descriptionText
的框架小?
(默认情况下scrollEnabled
和userInteractionEnabled
都是YES,所以这不会有帮助。)
答案 2 :(得分:1)
正如Hermann Klecker提到scrollEnabled
可以使用,您也可以尝试
_descriptionText.UserInteractionsEnabled =YES;
答案 3 :(得分:-1)
_descriptionText.textAlignment = NSTextAlignmentJustified;
_descriptionText.showsVerticalScrollIndicator = false;
_descriptionText.selectable = false;
_descriptionText.editable = false;