重播套件无法正常工作 IPAD IOS11 BUG

2023-12-15

我正在使用以下代码来录制屏幕。它工作得很好ios10 and ios9

 @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")
    }

}

我可以看到提示许可ios10 and ios9但不是为了ios11

ios11完成(关闭)块永远不会调用
我已经验证了该方法正确调用 if 条件if RPScreenRecorder.shared().isAvailable {还允许让

如果有人知道请帮助我

enter image description here

enter image description here


我遇到了和你一样的问题,所以我想更新到 iOS 11.0.2,它对我有用!希望它也能帮助你。

以防万一,这是我的方法:

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

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()
        }
    }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

重播套件无法正常工作 IPAD IOS11 BUG 的相关文章

随机推荐