iOS: Is it possible to take screenshots while runn

2019-01-15 17:37发布

I want to take screenshots of any running app, while my app is in the background.

I know I can take screenshots in iOS using:

UIGraphicsBeginImageContext(webview.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

But this is not really possible in a background task as UIGraphicsGetCurrentContext returns NULL and I want a screenshot of the running app and not my view. Is there any other way?

3条回答
我命由我不由天
2楼-- · 2019-01-15 18:09

Recording the screen from a background app seems to be possible, but not without jailbreaking your device. If you really need this capability for testing, you may find jailbreaking to be worth the hassle, but it's certainly not something you could include in an app that you plan to sell through the App Store.

查看更多
干净又极端
3楼-- · 2019-01-15 18:15

When running the stock OS, the iOS app security sandbox will prevent your app from having access to the contents of the view of any other app.

查看更多
你好瞎i
4楼-- · 2019-01-15 18:21

For security reasons, you will not be able to that.

I hope

查看更多
登录 后发表回答