UITextInput setMarkedText:selectedRange not working? (Can't be!)
- by nacho4d
I want to set the marked text programmatically and since iOS5 UITextView and UITextField conform to UITextInput this should be possible but for some reason I always get the markedText to be nil. :(
What am I missing here?
This is what I've tried without success:
(While the textview is firstResponder)
1.- When the text view contains no text:
text: "", selectedRange : {0,0}, markedText: nil.
[_textView setMarkedText:@"?" selectedRange:NSMakeRange(0, 1)];
Result:
text : "", selectedRange: {0,0}, markedText: nil. (Nothing changed)
2.- When the text view contains text + some marked text:
text : "AAA", selectedRange = {0,3}, marked text at the end : "??"
then I do:
[_textView setMarkedText:@"?" selectedRangeNSMakeRange(0,3)];
Result :
text :"AAA", selectedRange: {0,3}, markedText: nil; (the marked text became nil)
In both cases is like setMarkedText:selectedRange: would be setting the current marked text (if some) to nil.
Any help would be highly appreciated :)