ksh*_*ara 5 iphone objective-c uialertview ios
我弹出一个UIAlertView与UITextField它.我希望文本字段自动大写所有单词.我这样做是通过设置文本字段的属性来实现的,但它们在运行时没有任何影响.这是我的代码:
UIAlertView* alert = [[UIAlertView alloc] initWithTitle: title
message: message
delegate: self
cancelButtonTitle: @"Cancel"
otherButtonTitles: @"Create", nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField* titleField = [alert textFieldAtIndex: 0];
titleField.autocapitalizationType = UITextAutocapitalizationTypeWords;
[alert show];
Run Code Online (Sandbox Code Playgroud)
这个自动资本化正在UITextField表单上,XIB但这不适用于UIAlertView,我正在使用iOS 6.
如果它不会改变您的要求,请使用
titleField.autocorrectionType = UITextAutocorrectionTypeDefault;
Run Code Online (Sandbox Code Playgroud)
随着
titleField.autocapitalizationType = UITextAutocapitalizationTypeWords;
Run Code Online (Sandbox Code Playgroud)
给你想要的效果。