use*_*346 1 iphone cocoa-touch objective-c uitextview ios
我试图在代码的开头用uitextview显示垂直滚动条,但它没有这样做.
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];
Run Code Online (Sandbox Code Playgroud)
如果你只是写[textView flashScrollIndicators];
它,它只会在创建textView或加载页面时闪烁一次.没有任何代码或方法flashScrollIndicators
连续/永久显示.
为此,您需要以NSTimer
非常低的时间间隔获取帮助,并在计时器的方法中编写textView的flash指示器代码.这样的
[NSTimer scheduledTimerWithTimeInterval:0.001f target:self selector:@selector(flashIndicator) userInfo:nil repeats:YES]; // set time interval as per your requirement.
Run Code Online (Sandbox Code Playgroud)
通话方法
-(void)flashIndicator
{
//here you need to write code:
[txtView flashScrollIndicators];
}
Run Code Online (Sandbox Code Playgroud)
为了更清楚:
UITextView属于UIScrollView类.因此,您可以调用一个方法flashScrollIndicators来提示用户该视图是可滚动的.它只闪烁一次,持续几秒钟,用户进入包含UIScrollView或其子类的页面.您可以设置计时器以多次调用此方法.
归档时间: |
|
查看次数: |
2978 次 |
最近记录: |