0
我沒有調用「[sender resignFirstResponder]」方法,但按下完成按鈕時我的鍵盤仍然關閉。我需要它保持開放,即使點擊完成。我怎麼能這樣做呢?iOS UITextField將鍵盤保持在屏幕上
這裏是我的行動,控制鍵盤:
- (IBAction)returnKeyButton:(id)sender {
BOOL guessCorrect = [gameModel checkGuess:guessTextField.text];
guessTextField.text = @"";
if (guessCorrect) {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"rightAnswer", CFSTR ("mp3"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
if (gameModel.score == 10) {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"win", CFSTR ("mp3"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
[self endGameWithMessage:@"You win!"];
} else {
scrambledWord.text = [gameModel getScrambledWord];
}
}
remainingTime.text = [NSString stringWithFormat:@"%i", gameModel.time];
playerScore.text = [NSString stringWithFormat:@"%i", gameModel.score];
}
我很好奇......爲什麼? – citruspi 2012-04-23 21:54:36
問題是,你猜這個問題的答案。現在,我可以通過使用「返回」鍵來猜測答案,但每當我按下它時,鍵盤都會關閉。每次我想輸入答案時都不得不再次按下文本字段,這很讓人煩惱。 – 2012-04-23 21:56:14
給我幾分鐘...我有一個想法:) – citruspi 2012-04-23 21:59:54