我是xCode和Objective C的新手。我正在研究一个简单的计算器应用程序,只是为了学习...... 我尽我所能,用谷歌搜索并寻找答案,但我仍然坚持一些事情......
我有一个文本字段,当有人点击UIPickerView时会获取一个值。这工作正常,但当我点击我的完成按钮,使用下面的代码,它保持焦点。 我玩过EndFirstRepsonder和EndEditing,但都没有删除闪烁的光标...
作为旁注,动画只能在节目中使用一次,并且无法隐藏......
//Show Picker Wheel
- (IBAction)showPickerWheel:(id)sender
{
//This line hides the default keyboard
[sender resignFirstResponder];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.6];
CGAffineTransform transfrom = CGAffineTransformMakeTranslation(0, 20);
_pickerViewContainer.transform = transfrom;
_pickerViewContainer.alpha = 1;
[UIView commitAnimations];
}
//Hide Picker Wheel
- (IBAction)hidePickerWheel:(id)sender
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.6];
CGAffineTransform transfrom = CGAffineTransformMakeTranslation(0, 20);
_pickerViewContainer.transform = transfrom;
_pickerViewContainer.alpha = 0;
[UIView commitAnimations];
}
答案 0 :(得分:1)
您需要在didEndEditing委托方法中使用resignFirstResponder,如下所示:
(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}