简体   繁体   中英

How to replace Text in UITextInput?

I use UITextInput in customView:

MyCode: https://github.com/lequysang/github_zip/blob/master/UITextInputDebug.zip

@property (strong,nonatomic) id<UITextInput> textInput;

After typing some chars, I want to go back 4 chars and replace text at this position (replace any to T).Current cursor at the end.

How to do that?

I try replaceRange with UITextRange but don't know how to get position and size with it!

Please help! Thanks in advance!

replaceRange:withText:

Replace the text in a document that is in the specified range. (required)

- (void)replaceRange:(UITextRange *)range withText:(NSString *)text

Parameters

range

A range of text in a document.

text

A string to replace the text in range.

Availability Available in iOS 3.2 and later.

See Also

– textInRange: 

Declared In UITextInput.h

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM