Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

fladnag

macrumors newbie
Original poster
Oct 3, 2008
3
0
I am having a terrible time with issues taking screenshots, having spent hours messing with stuff and have been unable to figure it out or find any hep online.
The top set of code works but it makes the screenshot offset so that the top gets cut off and leaves a white strip at the bottom.
The bottom set of code does not work in the project I am having trouble with at all, but it does work in another very similar project.
I have spent hours trying to isolate where the difference between the projects is - trying to get the one working like the other one, or even get the other broken like the first so that I could figure out where the issue is. I have had no success.
Does anyone have any ideas why this is not working?
Can anyone give me a suggestion as to how to offset the screenshot in the other direction so that it is properly centered in the problem project? I have tried everything I could think of but nothing works. :mad:

Code:
CGRect screenRect = CGRectMake(0, 0, 320, 480);
		UIGraphicsBeginImageContext(screenRect.size);
		[self.layer renderInContext:UIGraphicsGetCurrentContext()];
		UIImage *sShot = UIGraphicsGetImageFromCurrentImageContext();
		UIGraphicsEndImageContext();
		UIImageWriteToSavedPhotosAlbum(sShot, nil, nil, nil);

Code:
UIGraphicsBeginImageContext(self.window.bounds.size);
		[self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
		UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
		UIGraphicsEndImageContext();
		UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.