Programação para iPhone: Desativar verificação ortográfica no UITextView
UITextAutocorrectionTypeNo não funcionou para mim.
Estou trabalhando em um aplicativo de palavras cruzadas para o iPhone. As perguntas estão em UITextViews e eu uso UITextFields para a entrada do usuário de cada letra. Ao tocar em uma pergunta (UITextView), o TextField da primeira resposta char se torna FirstResponder.
Tudo funciona bem, mas os UITextViews ainda estão com verificação ortográfica e marcam as palavras erradas na pergunta, mesmo que eu as defina UITextAutocorrectionTypeNo.
//init of my Riddle-Class
...
for (int i = 0; i < theQuestionSet.questionCount; i++) {
Question *myQuestion = [theQuestionSet.questionArray objectAtIndex:i];
int fieldPosition = theQuestionSet.xSize * myQuestion.fragePos.y + myQuestion.fragePos.x;
CrosswordTextField *myQuestionCell = [crosswordCells objectAtIndex:fieldPosition];
questionFontSize = 6;
CGRect textViewRect = myQuestionCell.frame;
UITextView *newView = [[UITextView alloc] initWithFrame: textViewRect];
newView.text = myQuestion.frageKurzerText;
newView.backgroundColor = [UIColor colorWithRed: 0.5 green: 0.5 blue: 0.5 alpha: 0.0 ];
newView.scrollEnabled = NO;
newView.userInteractionEnabled = YES;
[newView setDelegate:self];
newView.textAlignment = UITextAlignmentLeft;
newView.textColor = [UIColor whiteColor];
newView.font = [UIFont systemFontOfSize:questionFontSize];
newView.autocorrectionType = UITextAutocorrectionTypeNo;
[textViews addObject:newView];
[zoomView addSubview:newView];
[newView release];
}
...
//UITextView delegate methode in my Riddle-Class
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView {
textView.autocorrectionType = UITextAutocorrectionTypeNo;
for (int i = 0; i < [questionSet.questionArray count]; i++) {
if ([[[questionSet.questionArray objectAtIndex:i] frageKurzerText] isEqualToString:textView.text]) {
CrosswordTextField *tField = [self textfieldForPosition:
[[questionSet.questionArray objectAtIndex:i] antwortPos]];
markIsWagrecht = [[questionSet.questionArray objectAtIndex:i] wagrecht];
if ([tField isFirstResponder]) [tField resignFirstResponder];
[tField becomeFirstResponder];
break;
}
}
return NO;
}
Eu não chamo UITextView em nenhum outro lugar.