UITextview始终显示垂直滚动条 [英] UITextview show vertical scrollbar all the time

查看:426
本文介绍了UITextview始终显示垂直滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在uitextview上以代码
开头显示垂直滚动条,但是它没有这样做。

I am trying to show vertical scrollbar on uitextview at the beginning with the code but it isn't doing so.

UITextView *txtView=[[UITextView alloc]initWithFrame:CGRectMake(10, 80,self.view.frame.size.width-20,self.view.frame.size.height/2)];    
[txtView setEditable:NO];
[txtView setSelectable:NO];
[txtView setText:self.secret];
[txtView setBackgroundColor:[UIColor clearColor]];
[txtView setTextColor:[UIColor whiteColor ]];
[txtView setFont:font];
txtView.showsVerticalScrollIndicator=YES;
[txtView flashScrollIndicators];
[self.view addSubview:txtView];


推荐答案

如果您只写 [ textView flashScrollIndicators]; 在创建textView或加载页面时仅闪烁一次。没有任何代码可以连续/永久显示 flashScrollIndicators

If you just write [textView flashScrollIndicators]; it will flash only once when your textView is created or page is loaded. There is not any code or method which display flashScrollIndicators continuously/permanently.

为此,您需要获得帮助 NSTimer 的时间间隔非常短,并在计时器的方法中编写textView的Flash指示器代码。例如

For do it you need to take help of NSTimer with very low time interval, and write code of flash indicator of textView in method of the timer. such like

[NSTimer scheduledTimerWithTimeInterval:0.001f target:self selector:@selector(flashIndicator) userInfo:nil repeats:YES]; // set time interval as per your requirement. 

调用方法

-(void)flashIndicator
{
  //here you need to write code:
  [txtView flashScrollIndicators];
}

更多说明:


UITextView属于UIScrollView类。因此,您可以调用flashScrollIndicators方法来提示用户该视图可滚动。在用户进入包含UIScrollView或其子类的页面时,它仅闪烁几秒钟。您可以设置计时器多次调用此方法。

UITextView comes under UIScrollView class. So there is a method flashScrollIndicators that you can call to prompts the user that the view is scrollable. It only flashes once for few seconds where user comes to a page that contains UIScrollView or its subclass. You may set timer to call this method more than one time.

这篇关于UITextview始终显示垂直滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆