3
votes

I am working in iPhone application, Using UITextView to show multiple text inside it, when the user tab the screen, automatically scroll UITextView content from bottom to top (scrolling level slow) and its working fine, i want to increase scroll speed like 1,2,3,4,5,6...10, How to do this? Please help me.

Thanks in advance

I tried this:

     - (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];
}
2
Just as a code review. Variables and method should start with a lowercase letter. I don't know why but it's murder to read the other way. Additionally, you are unclear as to what you are asking. Are you just trying to implement a UISegmentedControl that has different speeds? - endy
What was the issue you are facing with above code? Have you tried with scrollsToTop property? - iDev

2 Answers

0
votes

The other way is to put the variable in - (void)autoscrollTimerFired:(NSTimer*)timer method in scrollPoint = CGPointMake(scrollPoint.x, scrollPoint.y + 1); line instead of just 1 put there some iVar instead and provide some mechanism for like say one + and - button to increase and decrease the speed.

0
votes

If its just about scrolling fast, you can minimize the time at which the timer function is called. And for scrolling slow, you can increase the time.

Let me know if you are looking for something else.