Re: Substituting characters in a UITextField
Re: Substituting characters in a UITextField
- Subject: Re: Substituting characters in a UITextField
- From: DKJ <email@hidden>
- Date: Fri, 26 Jun 2009 09:49:23 -0700
On 26-Jun-09, at 0:58 , Steve Fogel wrote:
You manipulate the text field's text property directly with methods
like replaceOccurrencesOfString:withString: or insertString:atIndex:
or deleteCharactersInRange:, and so on.
The methods you mention only work on mutable strings. I tried doing
this:
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string
{
if( [string isEqualToString:@"C"] )
{
NSString *newString =
[textField.text stringByReplacingCharactersInRange:range
withString:@"\u2192"];
textField.text = newString;
return NO;
}
return YES;
}
It gives me the character I want, where I want it. But then the cursor
jumps to the end of the field.
Is there a way of re-positioning the cursor in a UITextField? Perhaps
by manipulating a UITouch object?
dkj
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden