gpt4 book ai didi

iphone - UITextView 在 iPhone 中滚动(自动)?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:43:36 25 4
gpt4 key购买 nike

我在 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];
}

最佳答案

另一种方法是将变量放在- (void)autoscrollTimerFired:(NSTimer*)timer 方法中在 scrollPoint = CGPointMake(scrollPoint.x, scrollPoint.y + 1); 行而不是 1 放一些 iVar 代替并提供一些机制,比如一个 +- 按钮来增加和减少速度。

关于iphone - UITextView 在 iPhone 中滚动(自动)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13946128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com