【问题标题】:UITextView not showing scroll barsUITextView 不显示滚动条
【发布时间】:2011-06-08 12:48:57
【问题描述】:

我以编程方式制作了 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];

如何让滚动条显示?

【问题讨论】:

    标签: iphone cocoa-touch uitextview


    【解决方案1】:

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

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

    如果您将[txtView flashScrollIndicators]; 注释掉,那么它只会显示一次,以向用户表明可以滚动。

    我认为实现它的一种(丑陋的)方法是更频繁地调用 flashScrollIndicators,但这不是正确的解决方案。

    【讨论】:

      【解决方案2】:

      里面有文字吗?只有当文本大于视图大小时才会显示滚动条。

      【讨论】:

        【解决方案3】:

        虽然听起来很奇怪,但您是否曾经收集和删除/编辑 UITextView 的子视图?当从 UITextView(或 UIScrollView)调用子视图时,它也会返回它的滚动条。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-01-15
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-10-19
          相关资源
          最近更新 更多