当我展示 iAd_parentView(UIView)
并创建此图像时_parentView
。
我在 a 上显示此图像(resultingImage)UIImageView
,然后此图像为空白(全黑)。
如何以iAd
编程方式获取屏幕截图?
- (id)initWithView:(UIView *)currentView
{
self = [super init];
if (self) {
_parentView = currentView;
self.interstitial = [[ADInterstitialAd alloc] init];
self.interstitial.delegate = self;
}
return self;
}
- (void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd
{
[interstitialAd presentInView:_parentView];
[self takeScreenshot];
}
- (void)takeScreenshot
{
CGRect rect = CGRectMake(0, 0, _parentView.frame.size.width, _parentView.frame.size.height);
UIGraphicsBeginImageContext(rect.size);
[_parentView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}