我已经以编程方式制作了 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
/showsHorizontalScrollIndicator 仅在 ScrollView 处于事件状态时显示栏,并在几毫秒不活动后隐藏它。
如果您将 [txtView flashScrollIndicators];
注释掉,那么它只会显示一次,以向用户表明可以滚动。
我认为一种(丑陋的)实现方式是更频繁地调用 flashScrollIndicators,但这不是正确的解决方案。
关于iphone - UITextView不显示滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6278921/