Can someone show me how to move the textView cursor downward cause I don't know how to do it, Also where should I put it in the textViewDidBeginEditing(_ textView: UITextView) or in the textViewDidEndEditing(_ textView: UITextView) Thanks in advance
Asked
Active
Viewed 172 times
1 Answers
1
This will move coursor to the end of text:
func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
DispatchQueue.main.async {
textView.selectedRange = NSRange(location: textView.text.count, length: 0)
}
return true
}
If you want to begin text from a new line, add this, before return true:
textView.text = textView.text + "\n"
If you want to skip two lines, make it "\n\n", and so on.

David
- 857
- 1
- 11
- 25
-
the cursor didn't move – Somebody May 24 '19 at 18:57
-
@Jose Is your delegate is working? – David Davidoff just now – David May 24 '19 at 19:42
-
yeah, I Think so how can i check if my delegate works or not – Somebody May 24 '19 at 19:50
-
@Jose in textViewDidBeginEditing, print("It works"), and see if it gets printed in your debug console – David May 24 '19 at 19:52
-
it does print it, can you help me – Somebody May 24 '19 at 19:55
-
I want to have two lines down, how can I do that – Somebody May 24 '19 at 19:58
-
@Jose I edited my answer, check it out. Don't forget to upvote, and select it as a correct one. – David May 24 '19 at 20:25
-
your answer is the correct one, I can't upvote right now because it doesn't let me but since the answer is correct I put it a green check mark – Somebody May 24 '19 at 20:47
-
Hi it works but their a bug that I want to fix, it is that if the user taps at the top it will move to the top and I want it to be locked at the second line please help, thanks in advance – Somebody Jun 03 '19 at 19:00