这个scrollToCaretInTextView函数在Swift 2中工作,但在转换为Swift 3时,它有一条错误信息,我无法找到解决方案。
以下是代码:
@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)
}
错误消息是:
类型的价值' UITextView'没有会员&caretRectForPosition'
我该如何解决这个问题?
谢谢!