iPhone SDK:在文本字段(或textview)中禁用自动创建点(。) [英] iPhone SDK: disable auto creation of dot (.) in text field (or 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.
- 设置文本字段的委托
-
设置通知
- Set the delegate for the text field
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屋!