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?

4

1 回答 1

1

是的,您必须自己实现插入符号。请参阅 Apple 的SimpleTextInput示例。

于 2014-07-25T12:11:46.187 回答