我正在使用MBProgressHUD和STTwitter……我调用MBProgressHUD,然后从主线程加载twitter feed,然后隐藏HUD。不幸的是,HUD在收到响应后就会立即隐藏,而不一定是在数据完全下载之后。对此有解决方案吗?这也会发生在应用程序中其他地方的webviews上。谢谢!
[[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];
}];
});
}发布于 2014-08-17 14:32:03
我建议使用SVProgressHUD,它易于使用,实现了单例,并且具有更多的功能和控制
发布于 2014-08-17 14:28:38
移动隐藏在successBlock中的代码的HUD,如下所示
successBlock: ^(NSArray *statuses) {
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.view animated:YES];
});
self.twitterFeed =[NSMutableArray arrayWithArray:statuses];
[self.tableView reloadData];
}发布于 2014-08-17 15:49:02
尝试将dispatch_async更改为dispatch_sync。我认为这可能是因为dispatch_async在主线程上存在一些问题。
https://stackoverflow.com/questions/25346748
复制相似问题