I have a table view based application which loads data for the next view from a URL. The method for doing this is as follows:
To me, the above code should show the UIActionSheet at the same time as the network activity indicator, and then they should both be removed when the file has been downloaded.
Now, the network activity indicator does exactly what I'm after. It displays when a user taps on a cell, and once the data for the next view has been downloaded and displayed it disappears. The UIActionSheet, however, pops up after the network activity indicator has been removed and immediately disappears. In effect, it appears after the download has finished, and so instantly dismisses itself too.
Any ideas on how to get this working as I would expect? Am I doing something wrong?
Code:
-(void)downloadItem {
// Start network activity indicator.
app = [UIApplication sharedApplication];
app.networkActivityIndicatorVisible = YES;
// Bring up loading sheet.
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Please wait..." delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
sheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[sheet showInView:self.view];
// Download data.
itemDict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:http://something.com]];
// Dismiss loading sheet.
[sheet dismissWithClickedButtonIndex:0 animated:YES];
// Remove network activity indicator.
app.networkActivityIndicatorVisible = NO;
}
To me, the above code should show the UIActionSheet at the same time as the network activity indicator, and then they should both be removed when the file has been downloaded.
Now, the network activity indicator does exactly what I'm after. It displays when a user taps on a cell, and once the data for the next view has been downloaded and displayed it disappears. The UIActionSheet, however, pops up after the network activity indicator has been removed and immediately disappears. In effect, it appears after the download has finished, and so instantly dismisses itself too.
Any ideas on how to get this working as I would expect? Am I doing something wrong?