this scrollToCaretInTextView function was working in Swift 2, but on converting to Swift 3, it has an error message that I can't find a solution to.
Here is the code:
@IBOutlet weak var emailBody: UITextView!
override func didRotate(from fromInterfaceOrientation: UIInterfaceOrientation) {
scrollToCaretInTextView(textView: emailBody, animated: true)
}
func scrollToCaretInTextView(textView:UITextView, animated:Bool) {
var rect = emailBody.caretRectForPosition((textView.selectedTextRange?.end)!)
rect.size.height += textView.textContainerInset.bottom
textView.scrollRectToVisible(rect, animated: animated)
}
The error message is:
Value of Type 'UITextView' has no member 'caretRectForPosition'
How can I fix this please?
Thanks!
In Swift 3 method signature is changed like
caretRect(for:)