简体   繁体   English

重播套件不工作IPAD IOS11 BUG

[英]Replay kit Not working IPAD IOS11 BUG

I am using following code to record screen.我正在使用以下代码来记录屏幕。 It is working fine for ios10 and ios9它适用于ios10ios9

 @IBAction func btnRecordTapped(_ sender: UIButton) {

    if RPScreenRecorder.shared().isAvailable {


        if #available(iOS 10.0, *) {
            RPScreenRecorder.shared().startRecording(handler: { (error) in
                guard error == nil else {
                    print("Record failed with error \(error!.localizedDescription)")
                    return
                }

                DispatchQueue.main.async {
                    sender.removeTarget(self, action: #selector(self.btnRecordTapped(_:)), for: .touchUpInside)
                    sender.addTarget(self, action: #selector(self.stoprecording(button:)), for: .touchUpInside)

                    sender.setTitle("Stop", for: .normal)
                    sender.setTitleColor(.red, for: .normal)


                }


            })
        } else {

            RPScreenRecorder.shared().startRecording(withMicrophoneEnabled: false, handler: { (error) in

                guard error == nil else {
                    print("Record failed with error \(error!.localizedDescription)")
                    return
                }

                DispatchQueue.main.async {
                    sender.removeTarget(self, action: #selector(self.btnRecordTapped(_:)), for: .touchUpInside)
                    sender.addTarget(self, action: #selector(self.stoprecording(button:)), for: .touchUpInside)

                    sender.setTitle("Stop", for: .normal)
                    sender.setTitleColor(.red, for: .normal)


                }

            })
        }
    } else {
        print("Screen Reocrder not availble")
    }

}

I can see Prompt for permission in ios10 and ios9 but not for ios11我可以在ios10ios9 中看到提示权限,但在ios11中看不到

ios11 Completion ( closure) block never calls ios11完成(关闭)块从不调用
I have already verified that method calls correctly if condition if RPScreenRecorder.shared().isAvailable { Also allows to let in if RPScreenRecorder.shared().isAvailable {也允许进入

Please help me if anyone know about it如果有人知道,请帮助我

在此处输入图片说明

在此处输入图片说明

I had the same problem as you, so I thinked in updating to iOS 11.0.2 and it worked for me!我和你有同样的问题,所以我想更新到 iOS 11.0.2 并且它对我有用! Hope it help you too.希望对你也有帮助。

Just in case, here are my methods:以防万一,这是我的方法:

let recorder = RPScreenRecorder.shared()

@IBAction func recordingAction(_ sender: Any) {
        if recorder.isRecording {
            stopRecordAction()
        } else {
            startRecordAction()
        }
}

func startRecordAction() {
     recorder.startRecording{ (error) in
            if let error = error {
               print("❗️",error)
             }
      }
}

func stopRecordAction() {
            recorder.stopRecording{ (previewVC, error) in
                if let previewVC = previewVC {
                    previewVC.previewControllerDelegate = self
                    self.present(previewVC, animated: true, completion: nil)
                    if let error = error {
                        print("❗️",error)
                    }
                }
            }
    }

Methods of RPPreviewViewControllerDelegate: RPPreviewViewControllerDelegate 的方法:

func previewControllerDidFinish(_ previewController: RPPreviewViewController) {
        dismiss(animated: true, completion: nil)
    }

    func previewController(_ previewController: RPPreviewViewController, didFinishWithActivityTypes activityTypes: Set<String>) {
        /// This path was obtained by printing the actiong captured in "activityTypes"
        if activityTypes.contains("com.apple.UIKit.activity.SaveToCameraRoll") {
            recordFinshedMessage()
        }
    }

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

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