小编gum*_*mmo的帖子

当JSON调用时间过长时,允许用户取消MBProgressHUD

我已经阅读并阅读了关于此的内容,我似乎无法找到符合我情况的任何内容.

当视图出现时我已经加载了MBProgressHUD,因为我的应用程序会立即获取一些web服务数据.我的问题是我的导航控制器上的后退按钮在显示HUD时没有响应(因此当应用程序获取其数据时).我希望用户能够点击以解除(或者在最坏的情况下能够点击后退按钮)以获得结果,如果这是无休止的等待.这是我的代码,只要视图出现就会运行:

#ifdef __BLOCKS__
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
hud.labelText = @"Loading";
hud.dimBackground = NO;
hud.userInteractionEnabled = YES;

dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
    // Do a task in the background
    NSString *strURL = @"http://WEBSERVICE_URL_HERE";

    //All the usual stuff to get the data from the service in here

    NSDictionary* responseDict = [json objectForKey:@"data"]; // Get the dictionary
    NSArray* resultsArray = [responseDict objectForKey:@"key"]; 


    // Hide the HUD in the main tread
    dispatch_async(dispatch_get_main_queue(), ^{

        for (NSDictionary* internalDict in resultsArray) 
        {
            for (NSString *key …
Run Code Online (Sandbox Code Playgroud)

xcode json uigesturerecognizer ios mbprogresshud

6
推荐指数
2
解决办法
7100
查看次数

标签 统计

ios ×1

json ×1

mbprogresshud ×1

uigesturerecognizer ×1

xcode ×1