0

I am using standard code to take a full screenshot of a scrollview. It works for most scenarios. However, I have a UICollectionView that uses AFNetworking's setImageWithURL to retrieve images. I want the user to be able to print or email the entire content with all images displayed. The problem is, if the offscreen images have not been scrolled to by the user, the screenprint always show the placeholder "Image Not Found" image.

My code:

   UIGraphicsBeginImageContext(scrollView.contentSize);
    {
    CGPoint savedContentOffset = scrollView.contentOffset;
    CGRect savedFrame = scrollView.frame;
    scrollView.contentOffset = CGPointZero;
    scrollView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height);

    if ([self respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)])
        [scrollView drawViewHierarchyInRect:scrollView.frame afterScreenUpdates:NO];
    else
        [scrollView.layer renderInContext:UIGraphicsGetCurrentContext()];

    image = UIGraphicsGetImageFromCurrentImageContext();


    scrollView.contentOffset = savedContentOffset;
    scrollView.frame = savedFrame;
}

UIGraphicsEndImageContext();

I've tried putting the thread to sleep to "wait" for the images to get loaded but that didn't work. Ideas would appreciated. Thanks!

Stacie
  • 123
  • 1
  • 7
  • possible duplicate of [Getting a screenshot of a UIScrollView, including offscreen parts](http://stackoverflow.com/questions/3539717/getting-a-screenshot-of-a-uiscrollview-including-offscreen-parts) – klcjr89 Jul 25 '14 at 20:59
  • have you taken a look at this? http://stackoverflow.com/questions/18590620/ios-sdk-how-to-screen-shot-content-of-tableview – u_ser722345 Jul 25 '14 at 21:04
  • No, I read both of those before posting. My coded is essentially the same as their solutions. It's rendering the entire scrollview and the textual portions, just not the images that are asynchronously retrieved using AFNetworking. – Stacie Jul 25 '14 at 21:14

0 Answers0