iOS 9将UITextView滚动到顶部 [英] iOS 9 scroll UITextView to top
问题描述
在iOS 7和/或8中,以编程方式将我的 UITextView
滚动到顶部按照预期在 viewDidLoad
中工作:
In iOS 7 and/or 8, scrolling my UITextView
to the top programmatically works as intended in viewDidLoad
:
[self.someTextView scrollRangeToVisible:NSMakeRange(0, 0)];
现在它只是加载到我的其他框架。我的猜测是它加载到我的contentOffset UIEdgeInsetsMake(0,0,65,0)
Now it just loads to my some other frame. My guess is it's loading to my contentOffset UIEdgeInsetsMake(0, 0, 65, 0)
我如何制作这项工作> = iOS9?
How do I make this work >=iOS9?
注意:我已经尝试放入 viewDidAppear
但没有结果
Note: I've already tried placing in viewDidAppear
with no results
编辑问题出现在我的 UITextView $ c $的情况下c>文本大于其视图的高度。我使用
UIEdgeInsets
因为视图以模态方式呈现,并且比屏幕边界稍大。但是,在这种情况下, scrollRangeToVisible
仍然适用于iOS 7/8但不适用于iOS9
EDIT The issue occurs in circumstances when my UITextView
text is greater than the height of it's view. I use UIEdgeInsets
because the view is presented modally, and is somewhat larger than the screen bounds. However, the scrollRangeToVisible
still works iOS 7/8 but not iOS9, in this circumstance
推荐答案
尝试将代码放在 viewDidLayoutSubviews
这篇关于iOS 9将UITextView滚动到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!