iPhone SDK:禁用自动创建点的文本字段(或的TextView)的()。 [英] iPhone SDK: disable auto creation of dot (.) in text field (or textview)

查看:154
本文介绍了iPhone SDK:禁用自动创建点的文本字段(或的TextView)的()。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已禁用自动校正类型我的文本字段,
和它不显示任何其他自动校正,

I've disabled auto-correction type for my text field, and it does not show any other auto-correction,

但它仍然会自动创建一个点(。),当我preSS空格键两次。

but it still automatically creates a dot (.) when I press space key twice.

例如,
如果我写测试和preSS空格键两次,
它会自动切换到测试。

For example, if I write "test" and press space key twice, it automatically changes into "test. "

任何人知道如何禁用此功能?

Anyone knows how to disable this feature?

非常感谢。

推荐答案

我找到了一个解决方案 - 它使用UITextFieldTextDidChangeNotification因为这种自动校正应用于后发生。

I found one solution - it uses UITextFieldTextDidChangeNotification because this occurs after the auto-correction applies.


  1. 将委派文本字段

  2. 设置的通知

  1. Set the delegate for the text field
  2. Set up a notification

- (无效)viewDidLoad中{

    ...

    [NSNotificationCenter defaultCenter]的addObserver:自

    选择:@选择(textFieldDidChange :)

    名称:UITextFieldTextDidChangeNotification对象:tfTitle];

    }

然后,通知处理程序

- (无效)textFieldDidChange:(NSNotification *)aNotification

{

    如果([的TextField.text rangeOfString:@]。长度){

    //更改文本

    的TextField.text = [的TextField.text stringByReplacingOccurrencesOfString:@ withString。:@];

}

}

这篇关于iPhone SDK:禁用自动创建点的文本字段(或的TextView)的()。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆