iOS:在作为后台任务运行时是否可以截取屏幕截图? [英] iOS: Is it possible to take screenshots while running as a background task?

查看:362
本文介绍了iOS:在作为后台任务运行时是否可以截取屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想截取任何正在运行的应用程序的截图,而我的应用程序在后台。

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

我知道我可以使用以下方式在iOS中截取屏幕截图:

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);

但这在背景任务中是不可能的,因为UIGraphicsGetCurrentContext返回NULL并且我想要一个截图运行应用程序而不是我的视图。还有其他办法吗?

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?

推荐答案

在运行股票操作系统时,iOS应用安全沙箱将阻止您的应用访问任何其他应用程序的视图内容。

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.

这篇关于iOS:在作为后台任务运行时是否可以截取屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆