在目标c中隐藏键盘 [英] Hide Keyboard in objective c

查看:58
本文介绍了在目标c中隐藏键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在视图中有几个文本框,其中一个用于写国家/地区.
我希望当您在另一个区域的testField国家/地区中向上按时,您可以使用UIPickerView选择国家/地区.
然后,放置与_tfCountry事件编辑已开始"关联的以下代码.

I have several textfields in a view, and one to write the country.
I wish that when you press up in the testField country that was to another view where you have a UIPickerView to select the country.
Then place the following code associated with the event "Editing did begin" of _tfCountry.

- (IBAction)countryPressed:(id)sender {
    [_tfCountry endEditing:YES];

    [_tfAdress  resignFirstResponder];
    [_tfCountry  resignFirstResponder];
    [_tfName  resignFirstResponder];
    [_tfEmail  resignFirstResponder];
    [_tfTelephone  resignFirstResponder];
    [_tfTaxID  resignFirstResponder];

    [self save];
    _picker = [self.storyboard instantiateViewControllerWithIdentifier:@"PickerCountry"];
    _picker.delegate = self;

    [self.navigationController pushViewController:_picker animated:YES];
}

但是键盘并没有消失.
他仍保留在下一个视图的屏幕和拍击按钮上.

But the keyboard does not disappear as it should.
he remains on the screen and slap buttons of the next view.

他不应该对"resignFirstResponder"轻视吗?
我在做什么错了?

he should not depararecer with "resignFirstResponder"?
what am I doing wrong?

我尝试

[self.view endEditing:YES]

并且不起作用.

如果我评论更改视图的部分,键盘不会消失,但会停止将数据发送到文本字段

if I comment the part of change of view, the keyboard does not disappear but stops sending data to the textfield

推荐答案

尝试延迟隐藏它.

    [self performselector:@selector(hideKB) withObject:nil afterDelay:0.1];


  -(hideKB){

   [_tfAdress  resignFirstResponder];
   [_tfCountry  resignFirstResponder];
   [_tfName  resignFirstResponder];
   [_tfEmail  resignFirstResponder];
   [_tfTelephone  resignFirstResponder];
   [_tfTaxID  resignFirstResponder];
    }

这篇关于在目标c中隐藏键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆