0

I have the attached code in my application that takes a screenshot of the view before emailing it. It works fine for Portrait mode but cuts off a section in Landscape mode. Running on IOS7. Can anyone help me please ?

UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshotimage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(screenshotimage, nil, nil, nil);
  • I kind of doubt it will make a difference here, but the `CGGeometry.h` reference says not to directly access the members of `CGRect` structs, and instead to use `CGRectGetWidth()` and `CGRectGetHeight()`. It’s good practice, and it would be worth a try here. – Zev Eisenberg Aug 21 '14 at 21:49
  • That is, your first line should read: `UIGraphicsBeginImageContext(CGSizeMake(CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds));` (You can split it into multiple lines or make the size a variable if you want to make it cleaner.) – Zev Eisenberg Aug 21 '14 at 21:50
  • Hmmm Still getting my landscape screenshots with the last 1/3 cut off when it creates an image file ? – user2628141 Aug 24 '14 at 14:13

0 Answers0