I added a very large text to the UItextView. My initial offset is -55. Then I scrolled to the end of the UITextView. My offset is 406.
Then I called scrollToZero. My offset is -55. I called scrollToZero again, and my offset is 0. Why is scrollToZero so unpredictable? I do not understand why the bias changed when I pressed again.
-(void) viewDidLoad { [super viewDidLoad]; textView.text = @"Very big text"; textView.contentInset = UIEdgeInsetsMake(55.0, 0, 0, 0); [textView scrollRectToVisible:CGRectMake(0,0,1,1) animated:NO]; } -(IBAction) scrollToZero:(id)sender { [textView scrollRectToVisible:CGRectMake(0, 0, textView.frame.size.width, textView.frame.size.height) animated:NO]; } -(IBAction) onLog:(id)sender { NSLog(@"___content offset %f", textView.contentOffset.y); }
Voloda2
source share