UITextField右对齐iOS 7

我有一个问题,当在iOS7上对齐一个UITextField时,当用户键入“空格”时,它不会马上出现.如果我键入另外一个字符空格出现.

在iOS 6中并没有发生

http://www.blogosfera.co.uk/2013/10/ios-7-whitespace-not-visible-to-uitextfield-with-right-alignment/

任何人都知道如何解决这个问题?

解决方法

-(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;
}

从文本中删除代码

self.txtFirstName.text = [self.txtFirstName.text stringByReplacingOccurrencesOfString:@"\u00a0" withString:@" "];

从这个stackoverflow答案 – UITextField spacebar does not advance cursor in iOS 7

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...