後不消失,我相信這是我的iOS/ObjC小白岬的一個問題...MBProgressHUD調用隱藏
我有在項,當用戶選擇一個排一個UITableView,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
...
[self.twitter sendUpdate:[self getTweet]];
和
- (NSString *)sendUpdate:(NSString *)text;
{
NSLog(@"showing HUD");
self.progressSheet = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication] keyWindow] animated:YES];
self.progressSheet.labelText = @"Working:";
self.progressSheet.detailsLabelText = text;
// Build a twitter request
TWRequest *postRequest = [[TWRequest alloc] initWithURL:
[NSURL URLWithString:@"http://api.twitter.com/1/statuses/update.json"]
parameters:[NSDictionary dictionaryWithObject:text
forKey:@"status"] requestMethod:TWRequestMethodPOST];
// Post the request
[postRequest setAccount:self.twitterAccount];
// Block handler to manage the response
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
NSLog(@"Twitter response, HTTP response: %i", [urlResponse statusCode]);
NSLog(@"hiding HUD");
[MBProgressHUD hideHUDForView:[[UIApplication sharedApplication] keyWindow] animated:YES];
self.progressSheet = nil;
它調用內置的Twitter API發送鳴叫。在發送過程中,我正在使用MBProgressHUD。 HUD消失後,我的行爲越來越不穩定,通常它會比應該延長10秒左右。根據我看到的顯示/隱藏日誌記錄。
我有另一個更簡單的視圖,它只是列出推文並且使用HUD沒有問題 - 儘管它通過viewWillAppear調用完成。
也許我需要通過另一個線程來顯示?
預先感謝任何想法〜克里斯
爲什麼把你的平視顯示器安裝到窗戶上?將它附加到您的視圖更有意義。此外,然後,而不是使用hideHUDforView方法爲什麼不只是調用hide:在您的propertySheet HUD上動畫,您已經有一個參考?這會提供幫助。 – peterept 2012-02-11 12:06:53
謝謝 - 就像它在一些常見的代碼中一樣,我避免傳遞視圖。我曾嘗試過,但沒有幫助。試圖切換到使用hide:call,但沒有更好的。我在稍後的didSelectRow調用中進行了一些GC調用,但添加了一些日誌記錄顯示,這不是阻塞。 – 2012-02-11 17:17:32