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

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

问题描述

我已为我的文字栏位停用自动更正类型,
,但没有显示任何其他自动更正,

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

例如,如果我写test并按空格键两次,

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 < br>
selector:@selector(textFieldDidChange :)

name:UITextFieldTextDidChangeNotification object:tfTitle];

}

然后,通知处理程序

- (void)textFieldDidChange:(NSNotification *)aNotification

{

if([textField.text rangeOfString:@。] .length){

//更改文本

textField.text = [textField.text stringByReplacingOccurrencesOfString: @。withString:@];

}

}

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

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