I have a problem, when Right Aligning a UITextField on iOS7, when the user types "Space" it wont appear right away. If I type another character the spaces appears.
In iOS 6 does is not happening
http://www.blogosfera.co.uk/2013/10/ios-7-whitespace-not-visible-to-uitextfield-with-right-alignment/
Anyone know how to fix this?
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (range.location == textField.text.length && [string isEqualToString:@" "]) {
// ignore replacement string and add your own
textField.text = [textField.text stringByAppendingString:@"\u00a0"];
return NO;
}
// for all other cases, proceed with replacement
return YES;
}
To remove the code from text
self.txtFirstName.text = [self.txtFirstName.text stringByReplacingOccurrencesOfString:@"\u00a0" withString:@" "];
FROM this stackoverflow answer - Right aligned UITextField spacebar does not advance cursor in iOS 7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With