1

我有一个UITextView命名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;

请注意,我已经设置:

_viewDescription.userInteractionEnabled = YES;

我怎样才能让它工作?

编辑1:我也尝试了所有这些事情,但没有任何改进:

[_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];

编辑 2:这是 _viewDescription:

_viewDescription = [[UIView alloc] initWithFrame:CGRectMake( self.frame.size.width + 20, 110, 230, 140)];

这是自定义滑块视图:

_sliderView = [[PTSlidersDimension alloc] initWithFrame:CGRectMake(350, 270, 390, 250)]

请注意,PTSliderDimension 是继承自 UIView 的自定义类。

4

4 回答 4

1

你有什么框架viewDescription?可能它比你的框架小descriptionText

(默认情况下两者都是 YES scrollEnableduserInteractionEnabled所以这无济于事。)

于 2012-12-13T11:12:33.607 回答
1

正如Hermann Klecker所说scrollEnabled,可以使用,您也可以尝试

_descriptionText.UserInteractionsEnabled =YES;
于 2012-12-13T11:17:33.553 回答
1

添加

_descriptionText.scrollEnabled    = YES;
于 2012-12-13T11:09:34.920 回答
-1
_descriptionText.textAlignment                       =   NSTextAlignmentJustified;
    _descriptionText.showsVerticalScrollIndicator        =   false;
    _descriptionText.selectable                          =   false;
    _descriptionText.editable                            =   false;
于 2018-03-21T09:42:46.867 回答