问题描述
即使显示了“允许在$ AppName中进行屏幕录像”弹出窗口,也永远不会输入startRecording()完成处理程序。有时会显示“允许$ AppName中的屏幕录像”弹出窗口。当我删除应用程序,重新启动设备并在项目上进行清理/构建时,也会发生这种情况。我正在使用具有iOS 11和Xcode 9的iPad Air 2。
研究
这个问题在早期版本中似乎也是一个问题,请参见此处:replaykit startrecording有时永远不会进入完成处理程序 我不赞成关闭WiFi或拥有稳定的互联网连接可以解决此问题,在iOS中也无法解决此问题11。
这是我正在使用的代码:
@IBAction func recordButtonTapped(_ sender: UIButton) {
if !recorder.isRecording {
startRecording(sender)
} else {
stopRecording(sender)
}
}
private func startRecording(_ sender: UIButton) {
guard recorder.isAvailable else {
print("Recording is not available at this time.")
// Display UI for recording being unavailable
return
}
recorder.startRecording(handler: { (error) in
guard error == nil else {
print("There was an error starting the recording.")
print(error!)
return
}
print("Started Recording Successfully")
DispatchQueue.main.async …Run Code Online (Sandbox Code Playgroud)