代码片段1

判断是否在主线程执行

//隐藏加载框
+ (void)hiddenLodingHUDFromView:(UIView *)view animated:(BOOL)animated
{
    if ([[NSThread currentThread] isMainThread]) {
        [MBProgressHUD hideHUDForView:view animated:animated];
    } else {
        dispatch_sync(dispatch_get_main_queue(), ^{
            [MBProgressHUD hideHUDForView:view animated:animated];
        });
    }
}

你可能感兴趣的:(代码片段1)