Code = -5807“录制因多任务和内容而中断 调整大小”
我有此代码,但是如果我重设设备或尝试在其他设备上使用它,我会一直看到这欧元
我使用ReplayKit
,但是我无法录制了
import UIKit import ReplayKit
class ViewController: UIViewController, RPPreviewViewControllerDelegate {
@IBOutlet var statusLabel: UILabel!
@IBOutlet var colorPicker: UISegmentedControl!
@IBOutlet var colorDisplay: UIView!
@IBOutlet var recordButton: UIButton!
@IBOutlet var micToggle: UISwitch!
let recorder = RPScreenRecorder.shared()
private var isRecording = false
override func viewDidLoad() {
super.viewDidLoad()
recordButton.layer.cornerRadius = 32.5
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func viewReset() {
micToggle.isEnabled = true
statusLabel.text = "Ready to Record"
statusLabel.textColor = UIColor.black
recordButton.backgroundColor = UIColor.green
}
@IBAction func colors(sender: UISegmentedControl) {
switch sender.selectedSegmentIndex {
case 0:
colorDisplay.backgroundColor = UIColor.red
case 1:
colorDisplay.backgroundColor = UIColor.blue
case 2:
colorDisplay.backgroundColor = UIColor.orange
case 3:
colorDisplay.backgroundColor = UIColor.green
default:
colorDisplay.backgroundColor = UIColor.red
}
}
@IBAction func recordButtonTapped() {
if !isRecording {
startRecording()
} else {
stopRecording()
}
}
func startRecording() {
func start() {
guard recorder.isAvailable else {
print("Recording is not available at this time.")
return
}
if micToggle.isOn {
recorder.isMicrophoneEnabled = true
} else {
recorder.isMicrophoneEnabled = false
}
recorder.startRecording{ [unowned self] (error) in
guard error == nil else {
print("There was an error starting the recording.")
print("MyError:", error as Any)
return
}
print("Started Recording Successfully")
self.micToggle.isEnabled = false
self.recordButton.backgroundColor = UIColor.red
self.statusLabel.text = "Recording..."
self.statusLabel.textColor = UIColor.red
self.isRecording = true
}
}
DispatchQueue.main.async {
start()
}
}
func stopRecording() {
func stop() {
recorder.stopRecording { [unowned self] (preview, error) in
print("Stopped recording")
guard preview != nil else {
print("Preview controller is not available.")
return
}
let alert = UIAlertController(title: "Recording Finished", message: "Would you like to edit or delete your recording?", preferredStyle: .alert)
let deleteAction = UIAlertAction(title: "Delete", style: .destructive, handler: { (action: UIAlertAction) in
self.recorder.discardRecording(handler: { () -> Void in
print("Recording suffessfully deleted.")
})
})
let editAction = UIAlertAction(title: "Edit", style: .default, handler: { (action: UIAlertAction) -> Void in
preview?.previewControllerDelegate = self
self.present(preview!, animated: true, completion: nil)
})
alert.addAction(editAction)
alert.addAction(deleteAction)
self.present(alert, animated: true, completion: nil)
self.isRecording = false
self.viewReset()
}
}
DispatchQueue.main.async {
stop()
}
}
在每次使用iPhone XS Max或其他iPhone型号的设备休息后,每次收到此错误
Domain = com.apple.ReplayKit.RPRecordingErrorDomain代码= -5807 “录制由于多任务处理和内容调整大小而中断” UserInfo = {NSLocalizedDescription =记录被多任务中断 和内容调整大小})
答案 0 :(得分:0)
我遇到了同样的问题,我的设备甚至完全无法再次记录屏幕。
将设备更新到iOS 13.1.3修复了所有问题。