简体   繁体   中英

Text shifted up in the textView while i focus on Textview second time

I use Textview for insert message text but when i focus in textview second time after insert some text then already inserted text shifted upside. so text cut in the TextView. Any solution for this problem?

UITextView the subclass of UIScrollView. So you can discard scroll to top like this:

((UIScrollView*)someTextView).delegate = self; // or some other UIScrollViewDelegate

and implement this method:

-(void) scrollViewDidScroll:(UIScrollView*) scrollView {
    scrollView.contentOffset = CGPointMake(0, 0);
}

But if you do need scrolling during edit, you can add some boolean flags to distinguish the situations when user is scrolling and when the scrolling is automatic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM