snapshotViewAfterScreenUpdates iOS 8上的故障

Dan*_*e P 21 objective-c ios ios8 iphone-6 ios8.4

我注意到运行这会导致视图(或主窗口,不确定)调整片刻,当在iPhone 5/6 +模拟器上运行时,从iPhone 5布局缩放(不通过iPhone 6/6 +的启动图像):

[self.view snapshotViewAfterScreenUpdates:YES];
Run Code Online (Sandbox Code Playgroud)

当你不能在那里传递'NO'时,有什么想法让它工作吗?

更新(7月13日):
似乎不再在iOS 8.4上重现.

kga*_*dis 13

由于它似乎是一个Apple/API问题,我只是决定在我需要传递"YES"时不使用该方法.

您可以只截取视图的截图(UIImage)并将其放在UIImageView中,作为您从快照方法获取的"UIView".

这是一个代码链接: 如何在不损失视网膜显示质量的情况下捕获UIView到UIImage

#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;
}
Run Code Online (Sandbox Code Playgroud)

  • 它解决了我的大问题.很好的答案.我赞成你的好帖子 (2认同)