I am starting to learn iOS recently and now I am proceeding project to improve my skills.
In this project, I want users to to edit UITextView and when user touch UITextView I want users to edit the text at the point that they touched.
The problem when the text is way below, text is hidden by the keyboard when keyboard appears. When it happens, I want to move textView above so tapped location is just above the keyboard.
I've been googling all day but I couldn't find any suitable solution
The code below is most common solution in google but I couldn't understand what currentPoint and rect stands for. It is giving me values but I couldn't understand
If there's another way to solve this issue or help me understand code it would be very helpful
func textViewDidBeginEditing(_ textView: UITextView) {
let startPoint = textView.beginningOfDocument
let selectRange = textView.selectedTextRange
guard let range = selectRange else {
return
}
var currentPoint = textView.offset(from: startPoint, to: range.start)
let rect = textView.caretRect(for: range.end)
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…