Skip to content

Instantly share code, notes, and snippets.

@alex-zige
Created October 31, 2013 03:57
Show Gist options
  • Save alex-zige/7244178 to your computer and use it in GitHub Desktop.
Save alex-zige/7244178 to your computer and use it in GitHub Desktop.
GDC dispatch example
-(void)viewDidLayoutSubviews
{ [super viewDidLayoutSubviews];
dispatch_queue_t imageReader = dispatch_queue_create("Image Reader", NULL);
dispatch_async(imageReader, ^{
[NSThread sleepForTimeInterval:1];
UIImage *image = [UIImage imageNamed:self.imageName]; // may take time to load
dispatch_async(dispatch_get_main_queue(), ^{
self.imageView.image = image;
self.imageView.contentMode = UIViewContentModeTopLeft;
self.imageView.contentMode = UIViewContentModeTopLeft;
self.scrollView.contentSize = self.imageView.image.size;
self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment