2010-03-19 25 views
46

için Otomatik Kapatma/Oto Düzeltme devre dışı bırakılıyor Sorun, otomatik kapamayı ve UITextField'ımı otomatik olarak düzeltir olmamıza rağmen, yine de girdimin ilk harfini büyük harfle yazıyor.iPhone: Bir UITextField

UITextField* textField = [[[UITextField alloc] initWithFrame:CGRectMake(90.0, 10.0, 213.0, 25.0)] autorelease]; 
[textField setClearButtonMode:UITextFieldViewModeWhileEditing]; 
textField.returnKeyType = UIReturnKeyGo; 
textField.autocorrectionType = FALSE; 
textField.autocapitalizationType = UITextAutocapitalizationTypeNone; 
textField.delegate = self; 
if (inputFieldType == Email) { 
    label.text = @"Email:"; 
    textField.keyboardType = UIKeyboardTypeEmailAddress; 
    emailTextField = textField; 
    textField.placeholder = @"Email Address"; 
} else { // password 
    textField.secureTextEntry = TRUE; 
    label.text = @"Password:"; 
    if (inputFieldType == Password){ 
     textField.placeholder = @"Password"; 
     passwordTextField = textField; 
    } 
    if (inputFieldType == ConfirmPassword){ 
     textField.placeholder = @"Confirm Password"; 
     confirmPasswordTextField = textField; 
    } 

} 

bakınız ekran görüntüsü: Burada

kodudur bir BOOL sanki Sen FALSE için autocorrectionType kuruyorsun alt text http://grab.by/39WE

cevap

60

, ama aslında UITextAutocorrectionType tip vardır. Yani FALSE, UITextAutocorrectionTypeDefault olarak yorumlanıyor, bu da otomatik düzeltmenin muhtemelen etkinleştirildiği anlamına geliyor.

Bahse girerim, adres defterinizde "Phil" adını buldu ve eşleşecek şekilde büyük harfleri otomatik olarak düzeltir.

+1

ha! Karşı problemim vardı. Otomatik düzeltmeyi doğru şekilde devre dışı bıraktım - ancak FALSE - d'oh için otomatik büyük harf kullanımı ayarlandı! – philsquared

30

Amaç - Cı

-(void)textFieldDidBeginEditing:(UITextField *)textField 
{ 
    textField.autocorrectionType = FALSE; // or use UITextAutocorrectionTypeNo 
    textField.autocapitalizationType = UITextAutocapitalizationTypeNone; 

} 

Swift

func textFieldDidBeginEditing(textfield : UITextField) 
{ 
    textField.autocorrectionType = .No 
    textField.autocapitalizationType = .None 
    textField.spellCheckingType = .No 
} 

swift3

func textFieldDidBeginEditing(_ textField : UITextField) 
{ 
    textField.autocorrectionType = .no 
    textField.autocapitalizationType = .none 
    textField.spellCheckingType = .no 
} 
+0

Merhaba Anbu, NSTextfield (Mac uygulaması) için aynı seçeneği nasıl etkinleştirebiliriz (textField.autocorrectionType = FALSE; // veya UITextAutocorrectionTypeNo kullanın). Düşüncesi olan var mı? – Surezz

7
yourTextFieldName.autocorrectionType = UITextAutocorrectionTypeNo; 
yourTextFieldName.autocapitalizationType = UITextAutocapitalizationTypeNone; 
2

Swift 2:

textField.autocorrectionType = .No 
textField.autocapitalizationType = .None 
+1

Lütfen teklif verdiğiniz çözümün açıklamasını ekleyin. –