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

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

问题描述

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

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

但是当我按两次空格键时它仍然会自动创建一个点 (.).

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

例如,如果我写测试"并按两次空格键,它会自动变为测试".

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

- (void) viewDidLoad {
...
[[NSNotificationCenter defaultCenter] addObserver:self
选择器:@selector(textFieldDidChange:)
名称:UITextFieldTextDidChangeNotification 对象:tfTitle];
}

然后,通知处理程序
- (void)textFieldDidChange:(NSNotification *)aNotification
{
if ( [textField.text rangeOfString:@"."].length ) {
//更改文本
textField.text = [textField.text stringByReplacingOccurrencesOfString:@"." withString:@" "];
}
}

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

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