UIView with uiindicator sethidden = No not working after sethidden = YES

I have a uiView covering the screen with a label and uiindicator that runs when i am doing a network call.

Now here's the problem. I have initialized like this in viewdidload

[self.UiIndicator_view setHidden:YES];
[self.UiIndicator_label setHidden:YES];
[self.UiIndicator_indicator setHidden:YES];

On the network call i have called

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
            [self ShowIndicator:@"Syncing Data"];

            if([self CheckNetwork])
                [HttpMethods GetHeaderDataForAppHttp];
            dispatch_async(dispatch_get_main_queue(), ^
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Network Error"
                                                                  message:@"You have no network connection. Please connect to a network to sync data."

                [alertView show];
                [self StopIndicator];

and the methods are as follows

    [self.UiIndicator_view setHidden:NO];
    [self.UiIndicator_label setHidden:NO];
    [self.UiIndicator_label setText:labelText];
    [self.UiIndicator_indicator setHidden:NO];
    [self.UiIndicator_indicator startAnimating];

    [self.UiIndicator_view setHidden:YES];
    [self.UiIndicator_label setHidden:YES];
    [self.UiIndicator_indicator setHidden:YES];
    [self.UiIndicator_indicator stopAnimating];

Now the problem. The code runs perfectly fine when i start the app for first time. The call goes to dispatch_asyn, i see a UIView with label and indicator and after the call returns to main thread, the uiview and indicator disappears and i get the alertview if no data was fetched.

I have given the user an option to manually call the same function if data could not be fetched at first attempt. Here the issue arises, i can see in NSLOG that the method has been called, http request is fired, but i cannot see the uiview with indicator, even the elements and buttons that are supposed to be behind the uiview are not clickable (this means that there is a UIVIEW on top, but i cant see it). after some time i get the uialeart which means the call has completed.

Does setting uiview hidden = yes nullify it or something like that? i am not able to get this simple issue.


You are calling [self ShowIndicator:@"Syncing Data"]; on a background queue.

Only ever update the UI on the Main Queue.

More specifically:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
    [self ShowIndicator:@"Syncing Data"]; <<<< THIS IS YOUR PROBLEM

Need Your Help

How to change the class on one div while hovering over another div with AngularJS?

angularjs angularjs-directive

I want to change the class of one div while hovering over another div using AngularJS directives. Here is what I have so far http://jsfiddle.net/E8nM5/38/

MomentJS .format() produces correct date -1 day in my timezone

javascript jquery momentjs

I've noticed that when I use momentJs to output a date in a particular format in my timezone, that a day is lost.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.