Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何暂停语句执行和UIalertview在单独循环上运行_Ios_Objective C_Xmpp_Uialertview - Fatal编程技术网

Ios 如何暂停语句执行和UIalertview在单独循环上运行

Ios 如何暂停语句执行和UIalertview在单独循环上运行,ios,objective-c,xmpp,uialertview,Ios,Objective C,Xmpp,Uialertview,您好,我正在使用Xmpop聊天应用程序,正在进行文件转换,请求输入文件接受权限。对于这项任务,我使用这样的方法 UIAlertView *alrt = [[UIAlertView alloc]initWithTitle:@"Incommming File" message:name delegate:self cancelButtonTitle:@"Reject" otherButtonTitles:@"Accept", nil]; alrt.tag = 1111; [alrt

您好,我正在使用Xmpop聊天应用程序,正在进行文件转换,请求输入文件接受权限。对于这项任务,我使用这样的方法

UIAlertView *alrt = [[UIAlertView alloc]initWithTitle:@"Incommming File" message:name delegate:self cancelButtonTitle:@"Reject" otherButtonTitles:@"Accept", nil];
    alrt.tag = 1111;
    [alrt show];
    while (buttonClicked == -1)
    {
        NSLog(@"-- runloop");
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]];
    }
    if (buttonClicked == 1)
    {
        NSLog(@"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~YES");
        return YES;
    }
    else
    {
        NSLog(@"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~NO");
        return NO;
    }

这段代码在示例应用程序中工作,但在我的聊天应用程序中UI阻塞。我该怎么做请帮帮我。。提前谢谢。

试着打电话给
[alrt show]在异步块中

大概是这样的:

dispatch_async(dispatch_get_main_queue()) ^{
    [alrt show];
}  

希望这有帮助

你能分享这个例子的链接吗?你能告诉我这个
循环在哪个函数中被调用吗?上面的语句都属于'-(BOOL)incommingFileRequest:(XMPPIQ*)inIq'方法应该返回我们选择的BOOL,(接受或拒绝)你能分享这个例子的链接吗?