我正在使用ReplayKit录制屏幕,但当我在模拟器中运行应用程序时,我无法停止它,并且没有录制的视频预览,但我在输出控制台中收到以下消息。
2016-07-27 23:46:35.196 replay1[65028:4134788] plugin com.apple.ReplayKit.RPVideoEditorExtension interrupted
2016-07-27 23:46:35.196 replay1[65028:4134989] Hub connection error Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.ReplayKit.RPVideoEditorExtension" UserInfo={NSDebugDescription=connection to service named com.apple.ReplayKit.RPVideoEditorExtension}所以我试着在iPhone 6s上运行这个应用。
我收到了关于如何在应用程序中录制的提示,但当我尝试停止时,它不会停止,并且控制台中有一条消息
2016-07-27 21:29:43.118 replay[3009:968481] -[UIWindow endDisablingInterfaceAutorotationAnimated:] called on <UIWindow: 0x14ce56570; frame = (0 0; 375 667); gestureRecognizers = <NSArray: 0x14ce573f0>; layer = <UIWindowLayer: 0x14ce55480>> without matching -beginDisablingInterfaceAutorotation. Ignoring.此外,当我在应用程序中按stop时,它不会更改为start。
代码如下:
import ReplayKit
import UIKit
class ViewController: UIViewController, RPPreviewViewControllerDelegate
{
override func viewDidLoad()
{
super.viewDidLoad()
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .Plain, target: self, action: #selector(startRecording))
}
func startRecording()
{
let recorder = RPScreenRecorder.sharedRecorder()
recorder.startRecordingWithMicrophoneEnabled(true) { [unowned self] (error) in
if let unwrappedError = error
{
print(unwrappedError.localizedDescription)
} else
{
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Stop", style: .Plain, target: self, action: #selector(self.stopRecording))
}
}
}
func stopRecording()
{
let recorder = RPScreenRecorder.sharedRecorder()
recorder.stopRecordingWithHandler { [unowned self] (preview, error) in
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .Plain, target: self, action: #selector(self.startRecording))
if let unwrappedPreview = preview
{
unwrappedPreview.previewControllerDelegate = self
self.presentViewController(unwrappedPreview, animated: true, completion: nil)
}
}
}
func previewControllerDidFinish(previewController: RPPreviewViewController)
{
dismissViewControllerAnimated(true, completion: nil)
}
}我在哪里做错了?
谢谢。
另外,我刚刚开始iOS开发,所以我不能完全理解控制台中的消息在说什么。
发布于 2017-02-14 12:46:03
我从来没能让replayKit在模拟器中工作。我认为它依赖于硬件中的物理芯片来完成部分工作。
但我不确定你的错误中的自动旋转部分。
发布于 2017-08-18 14:47:53
//Replay kit doesn't work on simulator and will work on a physical device.
//Try this code hope it helps:
func startRecording() {
let recorder = RPScreenRecorder.shared()
if #available(iOS 9.0, *) {
recorder.startRecording(withMicrophoneEnabled: true) { [unowned self] (error) in
if let unwrappedError = error {
print(unwrappedError.localizedDescription)
} else {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Stop", style: .plain, target: self, action: #selector(PreviewVC.stopRecording))
}
}
} else {
// Fallback on earlier versions
}
}
func stopRecording() {
let recorder = RPScreenRecorder.shared()
recorder.stopRecording { [unowned self] (preview, error) in
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .plain, target: self, action: #selector(PreviewVC.startRecording))
if let unwrappedPreview = preview {
unwrappedPreview.previewControllerDelegate = self
self.present(unwrappedPreview, animated: true, completion: nil)
}
}
}
func previewControllerDidFinish(_ previewController: RPPreviewViewController) {
self.dismiss(animated: true, completion: nil)
}https://stackoverflow.com/questions/38620653
复制相似问题