-1
を閉じたとき、私は私のアプリがバックグラウンドにあるときに、実行中のアプリのスクリーンショットを取りたいスクリーンショットを撮ります。アプリが
私はapplicationDidEnterBackground方法でタイマーを設定します。
func applicationDidEnterBackground(_ application: UIApplication) {
var timer = Timer.scheduledTimer(timeInterval: 10, target: self, selector: #selector(self.takeSS), userInfo: nil, repeats: true)
}
そして、私はそれが10秒ごとに撮影し、カメラロールに保存し、画面をとるtakeSS
func takeSS(){
UIGraphicsBeginImageContextWithOptions((window?.bounds.size)!, false, UIScreen.main.scale)
self.window?.drawHierarchy(in: (window?.bounds)!, afterScreenUpdates: true)
var image:UIImage = UIGraphicsGetImageFromCurrentImageContext()!
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
}
と呼ばれるメソッドを作成しました。しかし、スクリーンショットは白と白の写真です。アプリが閉じられたときにスクリーン撮影を行う方法はありますか?
ありがとうございます。
バックグラウンド処理にはわずかな種類しかありません - https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/ TP40007072-CH4-SW4 - これはそれらの1つではありません。あなたは本質的に、サンドボックスアプリケーションが他のサンドボックスアプリケーションにどのようにスパイするかを尋ねています。 – Ssswift