gpt4 book ai didi

ios - GCD 和 progressHUD

转载 作者:行者123 更新时间:2023-11-28 22:00:16 24 4
gpt4 key购买 nike

使用任何形式的 progressHUD(SV、MB 等)我遇到了这个问题,即 HUD 在显示后立即隐藏或永久保留在那里。在下面的示例中,HUD 将永久保留,无论推特提要(或其他 View Controller 的页面)是否已完成加载。如何在单独线程中的任务完成后让 HUD 消失?

[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];
}];

});
}

最佳答案

应该是这样的:

[MBProgressHUD showHUDAddedTo:self.view animated:YES];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{

// do all your twitter stuff, including the error checking

dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
});
});

关于ios - GCD 和 progressHUD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25353525/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com