Swift3 UITextView将插入符号滚动到Swift 3中设备旋转时的可见文本
ScrollToCareTextView函数在Swift 2中工作,但在转换为Swift 3时,它有一条错误消息,我无法找到解决方案 代码如下:Swift3 UITextView将插入符号滚动到Swift 3中设备旋转时的可见文本,swift3,uitextview,caret,Swift3,Uitextview,Caret,ScrollToCareTextView函数在Swift 2中工作,但在转换为Swift 3时,它有一条错误消息,我无法找到解决方案 代码如下: @IBOutlet weak var emailBody: UITextView! override func didRotate(from fromInterfaceOrientation: UIInterfaceOrientation) { scrollToCaretInTextView(textView: emailBody, a
@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”
请问我该怎么修
谢谢 在Swift 3中,方法签名更改如下
能否请您添加截止日期不接受答案的原因是正确的,并且您在3个月后已不接受。您尚未回复,能否请您注意添加截止日期不接受答案的原因是正确的。
var rect = emailBody.caretRect(for: textView.selectedTextRange!.end)