resignFirstResponder仅在处理完成后发生 [英] resignFirstResponder only occurs after processing is complete

查看:283
本文介绍了resignFirstResponder仅在处理完成后发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望键盘在我的iPhone应用程序中点击提交时消失,而不是等到功能完成。该函数需要很长时间,因为我正在做一个同步的HTTP请求。

I want the keyboard to go away as soon as I hit "submit" in my iphone app, and not wait until the function completes. The function takes a long time because I'm doing a synchronous HTTP request.

视图不会更新,直到整个函数完成?我在xcode中的模拟器工作。

How come the view doesn't update until the whole function completes? I'm working in the simulator in xcode.

-(IBAction)submit:(id)sender{
    [myTitle resignFirstResponder];
    ...some ASIHTTP setup...
    [request startSynchronous];
    return;
}


推荐答案

当前同步HTTP请求,然后进行以下更改:

If you want to keep your current synchronous HTTP request then make these changes:

-(IBAction)submit:(id)sender{
    [myTitle resignFirstResponder];
    [self performSelector:@selector(delayedSubmit:) withObject:sender afterDelay:0];
}
-(void)delayedSubmit:(id)sender {
    ...some ASIHTTP setup...
    [request startSynchronous];
    //return;
}

我注释掉了 return; 因为它不需要在不返回任何像 void IBAction code> void ,但让IB知道要注意它)。

I commented out return; as it is not needed in methods that don't return anything like void and IBAction (which is really void but lets IB know to pay attention to it).

这篇关于resignFirstResponder仅在处理完成后发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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