gpt4 book ai didi

ios - UITextField 没有保持自动资本化

转载 作者:行者123 更新时间:2023-11-28 22:32:24 25 4
gpt4 key购买 nike

我在 UITextField 中的字符自动大写时遇到了一些问题。它在默认的 UIKeyboard 上工作得很好,但是如果我尝试使用 UIKeyboardTypeNamePhonePad,那么自动大写 dosnt 工作。

这是我的代码,

- (void)viewDidLoad {
//..

//get keyboard and textfield ready
codeTextField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 15.0, 300.0, 45.0)];

codeTextField.delegate = self;

UIFont *textFieldFont = [UIFont fontWithName:@"Helvetica" size:20.0];
[codeTextField setFont:textFieldFont];
codeTextField.textColor = [UIColor blackColor];

[codeTextField setKeyboardType:UIKeyboardTypeNamePhonePad];
[codeTextField setAutocapitalizationType:UITextAutocapitalizationTypeAllCharacters];
[codeTextField setAutocorrectionType:UITextAutocorrectionTypeNo];

//..

最佳答案

如果您查看自动大写属性的 UITextInputTraits 协议(protocol)引用,它指出:

Some keyboard types do not support auto-capitalization. Specifically, this option is ignored if the value in the keyboardType property is set to UIKeyboardTypeNumberPad, UIKeyboardTypePhonePad, or UIKeyboardTypeNamePhonePad.

关于ios - UITextField 没有保持自动资本化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17033424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com