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