IOS7 UITextView cursor problem, ios7uitextview

Source: Internet
Author: User

IOS7 UITextView cursor problem, ios7uitextview

Recently, in the project, when UITextView appears on ios7, the last line of the time mark disappears and the last line does not appear. The last line becomes blind. The stackOverFlow website pointed out that it is an iOS 7 bug, add the following code:

 1 -(void)textViewDidChange:(UITextView *)textView { 2     CGRect line = [textView caretRectForPosition: 3                    textView.selectedTextRange.start]; 4     CGFloat overflow = line.origin.y + line.size.height 5     - ( textView.contentOffset.y + textView.bounds.size.height 6        - textView.contentInset.bottom - textView.contentInset.top ); 7     if ( overflow > 0 ) { 8         // We are at the bottom of the visible text and introduced a line feed, scroll down (iOS 7 does not do it) 9         // Scroll caret to visible area10         CGPoint offset = textView.contentOffset;11         offset.y += overflow + 7; // leave 7 pixels margin12         // Cannot animate with setContentOffset:animated: or caret will not appear13         [UIView animateWithDuration:.2 animations:^{14             [textView setContentOffset:offset];15         }];16     }17 }

 

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.