iPhone: Stop UIScrollView from auto scrolling when

2019-07-01 15:13发布

Hi I have several UITextView's inside a UIScrollView. After a certain action occurs, I change the text of all the UITextView's using [info setText:@"blahblah"], then I modify each TextView's frame so that all the text is viewable. Then I change the content size of the UIScrollView so that it fits all the text.

The problem is that after I do this it scrolls when I would like for it to stay at the top of the screen. [scrollView setContentOffset:CGPointMake(0,0) animated:YES]; doesn't seem to keep the scrollView at the top.

Any Ideas?

3条回答
家丑人穷心不美
2楼-- · 2019-07-01 15:44

I used another view in mine, eg: UIWebView, and covered it up with a button. That only works for non-editable.

Try: How to stop UITextView from scrolling up when entering it

查看更多
够拽才男人
3楼-- · 2019-07-01 15:50

[scrollView setScrollsToTop:NO]; maybe?

查看更多
何必那么认真
4楼-- · 2019-07-01 15:55

you can use scrollRectToVisible:animated: to keep the scrollview at the top

查看更多
登录 后发表回答