I want to make my uitextview
to scroll automatically whenever the application is launched. Can anyone help me with a detailed code? I am new to iPhone SDK.
UITextView derives from UIScrollview so you can set the scrolling position using -setContentOffset:animated:.
Assuming you want to scroll smoothly at the speed of 10 points per second, you'd do something like that.
- (void) scrollStepAnimated:(NSTimer *)timer {
CGFloat scrollingSpeed = 10.0; // 10 points per second
NSTimeInterval repeatInterval = [timer timeInterval]; // ideally, something like 1/30 or 1/10 for a smooth animation
CGPoint newContentOffset = CGPointMake(self.textView.contentOffset.x, self.textView.contentOffset.y + scrollingSpeed * repeatInterval);
[self.textView setContentOffset:newContentOffset animated:YES];
}
Of course you have to setup the timer and be sure to cancel the scrolling when the view disappears and so on.