重播套件不工作IPAD

重播套件不工作IPAD

本文介绍了重播套件不工作IPAD IOS11 BUG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码来记录屏幕。它适用于 ios10 ios9

I am using following code to record screen. It is working fine for 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")
    }

}

I可以在 ios10 ios9 中看到提示权限,但 ios11

I can see Prompt for permission in ios10 and ios9 but not for ios11

ios11 完成(闭包)块从不调用

如果条件,如果RPScreenRecorder.shared()。isAvailable {还允许进入

ios11 Completion ( closure) block never calls
I have already verified that method calls correctly if condition if RPScreenRecorder.shared().isAvailable { Also allows to let in

如果有人知道,请帮助我

Please help me if anyone know about it

推荐答案

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

I had the same problem as you, so I thinked in updating to iOS 11.0.2 and it worked for me! 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)
                    }
                }
            }
    }

RPPreviewViewControllerDelegate的方法:

Methods of 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()
        }
    }

这篇关于重播套件不工作IPAD IOS11 BUG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 00:41