我已经以编程方式制作了UITextView,但是它没有显示垂直和水平滚动条。我使用的代码如下,

UITextView *txtView = [[UITextView alloc] initWithFrame:CGRectMake(origin, imgFrame.size.height + 10, mScrollView.frame.size.width, 300)];
txtView.font = [UIFont fontWithName:@"HelveticaNeue" size:12];
txtView.textColor = [UIColor blackColor];
txtView.textAlignment = UITextAlignmentLeft;
txtView.editable = NO;
txtView.scrollEnabled = YES;
txtView.backgroundColor = [UIColor clearColor];
[txtView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
//[txtView flashScrollIndicators];
[txtView setText:[mDescArr objectAtIndex:index]];
[mScrollView  addSubview:txtView];
[txtView release];


如何显示滚动条?

最佳答案

我认为没有常规方法可以使它们始终可见(故意!)。

BOOL txtView.showsVerticalScrollIndicator=TRUE / showsHorizo​​ntalScrollIndicator仅在滚动视图处于活动状态时显示该栏,并在不活动数毫秒后将其隐藏。

如果将[txtView flashScrollIndicators];注释掉,则仅显示一次,以向用户显示滚动的可能性。

我认为一种可行的(丑陋的)方法是,更频繁地调用flashScrollIndicators,但这不是适当的解决方案。

07-24 09:24