问题
I'm building an utility app for myself that can take screenshots of whatever is running in the foreground while this utility is running in the background. The utility will be running on a jailbroken device so it can access private APIs and not confined to the sandbox. Since the utility app is running in the background (either as a daemon or using backgrounder), how can I access the screen being displayed to generate a screenshot?
The reason I want this is because I want to take screenshots programmatically/remotely. The utility will take the screenshot and upload to my local server. I'm using this as part of internal test tools.
Help much appreciated!
回答1:
You should be able to grab a screenshot of the whole screen with UICreateScreenImage(). This will give you a CGImageRef, which you can turn into a UIImage with [UIImage imageWithCGImage:screenshot]
. You can then upload this to your server and release the image with CGImageRelease(screenshot)
.
来源:https://stackoverflow.com/questions/13338416/jailbroken-ios-taking-screenshot-from-background-app