iPhone: Stop UIScrollView from auto scrolling when UITextView text is changed

喜夏-厌秋 提交于 2019-12-12 13:17:50

问题


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?


回答1:


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




回答2:


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:


[scrollView setScrollsToTop:NO]; maybe?



来源:https://stackoverflow.com/questions/8139876/iphone-stop-uiscrollview-from-auto-scrolling-when-uitextview-text-is-changed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!