简体   繁体   中英

UITextView doesn't scroll to caret after becoming first responder on iOS 7

I have UITableViewCell and in this cell I have UITextView with some text. When I call becomeFirstResponder on iOS 6 then it works as expected and the table view scrolls to caret but this doesn't work on iOS 7 .

I have also UITextFields in cells and it works fine with becomeFirstResponder on iOS 7 . Just UITextView is a problem.

Is it a bug or what did they change?

I came up with my solution that utilizes a method (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated from UITableView and a method (CGRect)caretRectForPosition:(UITextPosition *)position from UITextInput and after doing some math with heights. I have achieved same behavior as on iOS 6. It is not so nice but it works.

If anyone will come with a better solution, let me know.

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