Iphone UITextField不会在整个项目中自动大写
出于某种原因,我的UITextFields都不会自动资本化。我在InterfaceBuilder中设置了属性,并按如下所示的编程方式设置了属性Iphone UITextField不会在整个项目中自动大写,iphone,objective-c,sdk,uitextfield,Iphone,Objective C,Sdk,Uitextfield,出于某种原因,我的UITextFields都不会自动资本化。我在InterfaceBuilder中设置了属性,并按如下所示的编程方式设置了属性 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"search_cell"]; UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(12, 10,
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"search_cell"];
UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(12, 10, 320, 32)];
tf.autocapitalizationType = UITextAutocapitalizationTypeWords;
tf.returnKeyType = UIReturnKeySearch;
tf.font = [UIFont boldSystemFontOfSize:20.0];
tf.delegate = self;
[cell addSubview:tf];
[tf becomeFirstResponder];
无论如何,我是否可以设置一些标志,在整个应用程序中禁用自动资本化,而没有意识到这一点
谢谢你检查过你的iPhone的设置->常规->键盘->自动大写吗?我发现如果你关闭自动更正,那么自动大写也不起作用。在我看来,他们应该独立运作。在名称字段中,人们希望将每个单词大写,但不会自动用字典预测的任何名称替换名称 无论设置如何,我都无法让它工作。所以我把它放在文本字段的委托中:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
// Handle the backspace.
if ([string isEqualToString:@""]) return YES;
// Otherwise convert to uppercase and change the textfield manually.
textField.text = [[textField.text stringByAppendingString:string] uppercaseString];
return NO;
}
还有一件事需要注意,在模拟器中,自动大写设置只影响模拟器键盘。因此,如果你用真正的键盘打字,它将不起作用。:)