• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Substituting characters in a UITextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Substituting characters in a UITextField
      • From: DKJ <email@hidden>
References: 
 >Re: Substituting characters in a UITextField (From: Steve Fogel <email@hidden>)

  • Prev by Date: Re: Hiding a running application
  • Next by Date: Re: Hiding a running application
  • Previous by thread: Re: Substituting characters in a UITextField
  • Next by thread: Re: Substituting characters in a UITextField
  • Index(es):
    • Date
    • Thread