Skip to content

Instantly share code, notes, and snippets.

@encryptio
Created August 22, 2010 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save encryptio/543182 to your computer and use it in GitHub Desktop.
Save encryptio/543182 to your computer and use it in GitHub Desktop.
- (void)loadImage {
NSURL *url = [db getImageURL:mnam node:nodeidx];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
[[URLHandler mainHandler] dataForURL:url sentTo:^(BOOL worked, NSData *data){
if ( !worked ) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Network Failure"
message:@"Couldn't download the comic. Make sure you're connected to a network."
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
[alert show];
[alert autorelease];
} else {
iv = [[UIImageView alloc] initWithImage:[UIImage imageWithData:data]];
sv.contentSize = CGSizeMake(iv.bounds.size.width, iv.bounds.size.height);
sv.scrollEnabled = YES;
sv.delegate = self;
[sv addSubview:iv];
[self doSizeCheck];
[self checkMarkCurrent];
}
[MBProgressHUD hideHUDForView:self.view animated:NO];
} withProgress:^(int current, int total){
if ( total != 0 ) {
hud.mode = MBProgressHUDModeDeterminate;
hud.progress = (float)current/total;
}
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment