Graphics xcode:尝试捕获部分屏幕

Graphics xcode:尝试捕获部分屏幕,graphics,xcode4,screenshot,Graphics,Xcode4,Screenshot,我一定是做错了什么,但我可以在以下方面提出一些建议: 我试图在iPad和iPad视网膜上捕捉部分屏幕 我可以得到纵向视图,但是我不能得到横向视图的右侧 这是我正在使用的代码(在UIGetScreenImage()被制成违禁品之前,我没有这个问题) 这是我为肖像画和风景画拍摄的两张照片: 如果您使用窗口作为框架,它将始终以纵向模式显示。您可以将screenRect设置为全屏视图,该视图应可在纵向和横向模式下工作。谢谢。我在谷歌上搜索和狂饮。。您是否有首选的设置方法。我能找到的最好方法是检查方向,

我一定是做错了什么,但我可以在以下方面提出一些建议:

我试图在iPad和iPad视网膜上捕捉部分屏幕

我可以得到纵向视图,但是我不能得到横向视图的右侧

这是我正在使用的代码(在UIGetScreenImage()被制成违禁品之前,我没有这个问题)

这是我为肖像画和风景画拍摄的两张照片:


如果您使用窗口作为框架,它将始终以纵向模式显示。您可以将screenRect设置为全屏视图,该视图应可在纵向和横向模式下工作。

谢谢。我在谷歌上搜索和狂饮。。您是否有首选的设置方法。我能找到的最好方法是检查方向,并手动设置坐标。戴维迪发现这篇文章很好,这给了我一个更好的方便方法。但你给了我正确的方向,我非常感激。所以我把它标记为关闭。。再次感谢你。
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext(); 
[[UIColor blackColor] set]; 
CGContextFillRect(ctx, screenRect);
[self.view.layer renderInContext:ctx];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();


CGImageRef imageRef = CGImageCreateWithImageInRect([img CGImage], CGRectMake (0, 100, self.view.bounds.size.width, (self.view.bounds.size.height - 200)));


UIImage *img2Save = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
// Request to save the image to camera roll
UIImageWriteToSavedPhotosAlbum(img2Save, self, nil, nil);