简体   繁体   English

如果应用程序在后台运行,如何以编程方式截取屏幕截图

[英]How to take a screenshot programmatically if the app is running in background

I am writing a piece of code using swift for iOS.我正在使用 swift for iOS 编写一段代码。

It's using location services.它正在使用位置服务。 I need to take a screenshot of the current screen every time the location gets updated.每次更新位置时,我都需要截取当前屏幕的屏幕截图。

The thing is when the app is running in background and updating the location the screenshots taken are from my app.问题是当应用程序在后台运行并更新截取的屏幕截图来自我的应用程序的位置时。 Not the app which is currently available in the screen.不是屏幕中当前可用的应用程序。

Assume that the user plays a game in their phone.假设用户在他们的手机中玩游戏。 But my app run in background and updating the location when the users location is significantly changed the screenshot should be taken and it should include the game.但是我的应用程序在后台运行并在用户位置发生重大变化时更新位置,应该截取屏幕截图并且它应该包括游戏。 Not my app screen.不是我的应用程序屏幕。

Can some one tell me how to achieve the screenshot capability I want.有人可以告诉我如何实现我想要的截图功能。

Short answer: You can't. 简短的回答:不能。

Apps can only take screenshots of their own content. 应用只能截取自己内容的屏幕截图。 Starting with (I think) iOS 7 Apple blocked the ability of apps to take screenshots of anything but their own content. 从(我认为)iOS 7开始,Apple阻止了应用对自己内容以外的任何内容进行屏幕截图的功能。 This is for security reasons. 这是出于安全原因。

Imagine your app echoes each character of your password as you type it, and then replaces it with a bullet as you type the next character. 想象一下,您的应用在键入密码时会回显密码的每个字符,然后在键入下一个字符时将其替换为项目符号。 Now imagine an app that runs in the background and takes a screen-shot every time your app displays a new character of the user's password. 现在,假设有一个应用程序在后台运行,并且每次您的应用程序显示用户密码的新字符时都会进行屏幕截图。

This sucks.这很糟糕。 So no way for parent to see what child was talking to child predator about?所以父母没有办法看到孩子在和儿童掠食者谈论什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM