Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.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
Iphone 我没有停下来_Iphone_Ios_Mbprogresshud - Fatal编程技术网

Iphone 我没有停下来

Iphone 我没有停下来,iphone,ios,mbprogresshud,Iphone,Ios,Mbprogresshud,这是我的密码 MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud.mode = MBProgressHUDModeIndeterminate; hud.labelText = @"Loading.."; dispatch_queue_t dispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); d

这是我的密码

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelText = @"Loading..";
dispatch_queue_t dispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(dispatchQueue, ^(void)
{
    [self information];
    [hud hide:YES];
});
我知道方法信息会在一段时间后完成。但即使完成后,进度条也不会移动。原因可能是什么?

像这样做吧

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelText = @"Loading..";
dispatch_queue_t dispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(dispatchQueue, ^(void)
{
[self information];
dispatch_sync(dispatch_get_main_queue(), ^{ 
[hud hide:YES];
});
}); 
像这样做

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelText = @"Loading..";
dispatch_queue_t dispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(dispatchQueue, ^(void)
{
[self information];
dispatch_sync(dispatch_get_main_queue(), ^{ 
[hud hide:YES];
});
}); 

尝试调用
[hud hide:YES]performSelectorOnMainThread:withObject:
method在主线程上执行code>,您能详细说明一下吗?我是一个新手。所以你现在得到了正确的答案,试着使用这个答案,这对你来说非常好:)试着调用
[hud hide:YES]performSelectorOnMainThread:withObject:
method在主线程上执行code>,您能详细说明一下吗?我是一个新手。所以你现在得到了正确的答案,试着用这个答案,它对你来说非常好:)很好!!你能解释一下我们到底做了什么吗?你把HUD隐藏在dispatch_async中,我的朋友不是主线程。您可以使用dispath\u sync或performselectornmainthread。记住,任何UI更新都应该在主线程和主线程中单独完成。效果很好!!你能解释一下我们到底做了什么吗?你把HUD隐藏在dispatch_async中,我的朋友不是主线程。您可以使用dispath\u sync或performselectornmainthread。记住,任何UI更新都应该在主线程和主线程中单独完成。