1

I notice in Apple's UITextInput protocol there is a required method called (CGRect)caretRectForPosition:(UITextPosition *)position that, as you can see, returns a CGRect. When I put a breakpoint inside of the method, it appears the method is never called even when I call the setSelectedTextRange: method. Do I have to implement my own caret object inside the text view? I thought the protocol automatically handled this and just added the caret into the text view with the frame specified by the CGRect returned by caretRectForTextPosition:. How would I go about showing/adding a caret to my UIView class that implements the UITextInput protocol?

EDIT

I have read the documentation all up and down with no results and even searched for example implementations by other people. I eventually just implemented the caret myself. Is that the right/suggested way to even do this?

rolling_codes
  • 15,174
  • 22
  • 76
  • 112
  • What do the official docs say? – nhgrif Jul 06 '14 at 14:31
  • That's my issue. I have read the documentation all up and down with no results and even searched for example implementations by other people. I eventually just implemented the caret myself. – rolling_codes Jul 06 '14 at 14:32
  • These details should be included in your question. – nhgrif Jul 06 '14 at 14:33
  • Duly noted @nhgrif I added an edit update to my question. Any way for this thread to recieve more views? I am still looking for a more concrete solution/answer than my own amatuer guesses and intuition – rolling_codes Jul 08 '14 at 13:15

1 Answers1

1

Yes, you do have to implement the caret yourself. See Apple's SimpleTextInput example.

Ser Pounce
  • 14,196
  • 18
  • 84
  • 169