I have a subclassed UITableViewCell named AccountView which contains an UIActivityIndicatorView. Each cell is supposed to contain a Twitter account. When the user posts a message to Twitter, the UIActivityIndicatorView is supposed to start spinning, then stop animating when the twitter request handler is executed:
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error){
if (error != nil) {
NSLog(@"TWITTER ERROR: %@",error);
}
NSLog(@"Posted successfully");
AccountCell *cell = (AccountCell *)[accountTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:[accounts indexOfObject:account] inSection:0]];
NSLog(@"Cell isSpinning? :%d",[[cell activity] isAnimating]);
[[cell activity] stopAnimating];
NSLog(@"Cell isSpinning? :%d",[[cell activity] isAnimating]);
}];
This all works fine when posting a short message to Twitter, however, when the TWRequest contains an image to be uploaded, after a few seconds, the post with image appears on Twitter, and I see the following message in the console:
2011-12-10 00:13:22.085 TwitTest[14954:1a03] Posted Successfully
2011-12-10 00:13:22.086 TwitTest[14954:1a03] Cell isSpinning? :1
2011-12-10 00:13:22.088 TwitTest[14954:1a03] Cell isSpinning? :0
But the UIActivityIndicatorView keeps spinning indefinitely (or at least a delay of several seconds), even though the Log messages indicate otherwise. The fact that this only breaks with image upload leads me to believe that maybe I should send the request on a background thread, but I have never dealt with threads before, and couldn't say for sure if that is the problem.
One last thing, if I navigate to different view and return, the UIActivityIndicatorView appears frozen - if I navigate away and return a second time, then it disappears for good.