RPScreenRecorder.shared.stopRecording блок не вызван - PullRequest
0 голосов
/ 25 ноября 2018

Я использую ReplayKit для записи изменений экрана.Я создал образец приложения для тестирования этой платформы.Блок stopRecording никогда не вызывается.Это проблема с Apple Framework?

class ViewController: UIViewController {
    @IBOutlet weak var imageView: UIImageView!
    let colors:[UIColor] = [UIColor.blue, UIColor.orange, UIColor.red, UIColor.blue]
    let recorder = RPScreenRecorder.shared()
    var isStarted = false
    override func viewDidLoad() {
        super.viewDidLoad()
        let count = self.colors.count
        // Do any additional setup after loading the view, typically from a nib.
        Timer.scheduledTimer(withTimeInterval: 1, repeats: true) {[weak self] (timer) in
            self?.view.backgroundColor = self?.colors[Int.random(in: 0..<count)]
        }

    }

    @IBAction func startOrStopRecorder(_ sender: Any) {
        let button = sender as! UIButton
        if self.isStarted{
            recorder.stopRecording { (preview, error) in
                print("stopped")
                if let thePreview = preview {
                    self.show(thePreview, sender: nil)
                }
            }
            button.setTitle("Start", for: .normal)
        } else {
            recorder.startRecording { (error) in
                print("started")
            }
            button.setTitle("Stop", for: .normal)
        }
        self.isStarted = !self.isStarted
    }

}
...