iphone - Dismiss MBProgressHUD when delegate method fires -
first time working hud , i'm confused.
i setup hud in viewdidload:
[mbprogresshud showhudaddedto:self.view animated:yes]; dispatch_async(dispatch_get_global_queue( dispatch_queue_priority_low, 0), ^{ [[[wsxmppusermanager shared] xmppstreammanager] connect]; dispatch_async(dispatch_get_main_queue(), ^{ [mbprogresshud hidehudforview:self.view animated:yes]; }); });
the hud doesn't show. think reason follows. xmpp connect
method fires off connection request xmpp server , it's done. there no activity wait is.
however, connection isn't established until server responds , following delegate method fired:
- (void)xmppstreamdidauthenticate:(xmppstream *)sender
i want wait , dismiss hud, i'm @ loss how that. i'm missing simple.
you need move code
dispatch_async(dispatch_get_main_queue(), ^{ [mbprogresshud hidehudforview:self.view animated:yes]; });
after long running method has finished... is, if code indeed returning immediately
[[wsxmppusermanager shared] xmppstreammanager] connect];
the hud never going display... gets told display , told hide on same run loop or perhaps 1 run loop right afterwards...
why not put @ end of method if indicates response has been received , operation completed?
- (void)xmppstreamdidauthenticate:(xmppstream *)sender
Comments
Post a Comment