我在 iPhone 应用程序中工作,使用 UITextView 在其中显示多个文本,当用户选项卡屏幕时,自动从下到上滚动 UITextView 内容(滚动级别慢)并且它工作正常,我想像 1 一样增加滚动速度, 2,3,4,5,6...10,如何做到这一点?请帮我。
提前致谢
我试过这个:
- (void)viewDidLoad
{
[super viewDidLoad];
ScriptDetails = [[UITextView alloc]initWithFrame:CGRectMake(0,9,480,285)];
ScriptDetails.text=Script;
ScriptDetails.textAlignment=UITextAlignmentLeft;
ScriptDetails.editable=NO;
ScriptDetails.delegate=self;
ScriptDetails.font=[UIFont fontWithName:str1 size:f];
ScriptDetails.backgroundColor=tColor1;
ScriptDetails.textColor=tColor;
[self.view addSubview:ScriptDetails];
UITapGestureRecognizer *singleTap = [[[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(TouchToPlay)] autorelease];
singleTap.delegate=self;
singleTap.numberOfTapsRequired = 1;
[ScriptDetails addGestureRecognizer:singleTap];
}
-(void)TouchToPlay
{
NSLog(@"single");
timer = [NSTimer scheduledTimerWithTimeInterval:(35.0/1000.0)
target:self
selector:@selector(autoscrollTimerFired:)
userInfo:nil
repeats:YES];
}
- (void)autoscrollTimerFired:(NSTimer*)timer
{
CGPoint scrollPoint = ScriptDetails.contentOffset;
scrollPoint = CGPointMake(scrollPoint.x, scrollPoint.y + 1);
[ScriptDetails setContentOffset:scrollPoint animated:NO];
}