Reputation: 1014
I am utilizing MBProgressHUD along with STTwitter...I call MBProgressHUD and then load the twitter feed off the main thread and hide the HUD thereafter. Unfortunately, the HUD hides as soon as it receives a response and not necessarily after the data has completely downloaded. Is there a solution to this? This also occurs with webviews elsewhere in the app. Thanks!
[[MBProgressHUD showHUDAddedTo:self.view animated:YES];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
//Sets the auth key (user or app) for the RMACC Twitter Feed
STTwitterAPI *twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {
[twitter getUserTimelineWithScreenName:@"RMACCNewsNotes" count: 10 successBlock:^(NSArray *statuses) {
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.view animated:YES];
});
self.twitterFeed =[NSMutableArray arrayWithArray:statuses];
[self.tableView reloadData];
}
errorBlock:^(NSError *error){
}];
} errorBlock:^(NSError *error) {
[self twitterselfauthrequest];
}];
});
}
Upvotes: 1
Views: 279
Reputation: 1837
Try changing dispatch_async
to dispatch_sync
.
I think this might be happening because of some issues dispatch_async has on main thread.
Upvotes: 0
Reputation: 1131
I would suggest using SVProgressHUD which is easy to use, implements Singleton, and with much more functionality and control
Upvotes: 1
Reputation: 1379
Move your HUD
hiding code inside successBlock
as follows
successBlock: ^(NSArray *statuses) {
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.view animated:YES];
});
self.twitterFeed =[NSMutableArray arrayWithArray:statuses];
[self.tableView reloadData];
}
Upvotes: 0