UITextView starting from bottom

谁都会走 提交于 2019-12-10 15:16:15

问题


I'm having trouble with a UITextView. I have seen other people have had this issue before, but whenever my app loads on my phone, all the UITextViews start from the bottom of their text and I have to scroll up.

I have tried numerous solutions but I need a solution to use on ONLY the Storyboard as I have some views without designated classes.

EDIT

I think this is happening when scrolling is enabled - so how do I have scrolling enabled but stop this from happening?


回答1:


Can not reproduce your issue on iOS 9.2,but you may try this

Set contentOffset with Runtime Attribtues




回答2:


I face same problem and I still cannot find a solution using Storyboard only.
However, using the code below can prevent your TextView auto start at bottom

If your TextView is in UIViewController

- (void)viewWillAppear:(BOOL)animated {
    [self.myTextView setContentOffset:CGPointZero];
}

If your TextView is in UIView

- (void)layoutSubviews{
    [self.myTextView setContentOffset:CGPointZero];
}

Hope this help




回答3:


Have you tried something like:

[self.textView scrollRangeToVisible:NSMakeRange(0, 0)];



来源:https://stackoverflow.com/questions/34452005/uitextview-starting-from-bottom

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