1

是否可以实例化UITextRange和 的第一个字符UITextField?我需要访问 rect 的UITextField第一个字符,有人可以帮助我吗?

提前致谢

4

1 回答 1

11

UITextRange您可以使用以下提供的方法手动创建UITextInput

UITextPosition *firstCharacterPosition = [textField beginningOfDocument];
UITextPosition *secondCharacterPosition = [textField positionFromPosition:firstCharacterPosition offset:1];
UITextRange *firstCharacterRange = [textField textRangeFromPosition:firstCharacterPosition toPosition:secondCharacterPosition];
NSString *firstCharacter = [textField textInRange:firstCharacterRange];
于 2014-03-13T03:52:39.897 回答