【发布时间】:2017-10-03 09:37:21
【问题描述】:
我正在使用以下代码来记录屏幕。它适用于 ios10 和 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 和 ios9 中看到提示权限,但在 ios11
中看不到ios11 完成(闭包)块从不调用
我已经验证了如果条件if RPScreenRecorder.shared().isAvailable { 也允许让方法调用正确
如果有人知道,请帮助我
【问题讨论】:
-
您是否尝试过物理设备?可能与https://stackoverflow.com/questions/40024316有关
-
@mato 感谢您的回复 模拟器不支持屏幕录制,提供的链接与问题无关
-
这里有一个相关线程:forums.developer.apple.com/thread/87007 在我的情况下,我重新启动了 iPad,并再次询问我是否在下次启动应用程序时授予屏幕录制权限,然后它又开始工作了.