Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

snapshotViewAfterScreenUpdates glitch on iOS 8

Tags:

I've noticed running this would cause view (or main window, not sure) to resize for a moment, when running on iPhone 6/6+ simulator scaled from iPhone 5 layout (without passing launch image for iPhone 6/6+):

[self.view snapshotViewAfterScreenUpdates:YES];

Any idea how to make it work when you can't pass 'NO' there?

Update (Jul 13th):
Does not seem to reproduce on iOS 8.4 anymore.

like image 493
Dannie P Avatar asked Sep 16 '14 15:09

Dannie P


1 Answers

Since it seemed like an Apple/API problem, I just decided to not use that method when I need to pass a "YES."

You can just take a screenshot (UIImage) of your view and place it in a UIImageView to act as the "UIView" you used to get from the snapshot method.

Here's a link for code: How to capture UIView to UIImage without loss of quality on retina display

#import <QuartzCore/QuartzCore.h>

+ (UIImage *) imageWithView:(UIView *)view
{
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return img;
}
like image 143
kgaidis Avatar answered Oct 21 '22 22:10

kgaidis