views:

263

answers:

1

I have a uitextview that is editable but there are certain characters I would like to be disallowed from being typed.

How can I do that?

+4  A: 

You can do this by assigning a delegate to the UITextView, and implementing the following method in the delegate:

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;

In the body just write some code that scans through the input text to see if you find the characters you want to filter, if you see them return NO, otherwise return YES.

Louis Gerbarg