ios - 在iOS swift中查看录音?

标签 ios iphone swift

是否有任何库可以记录特定UIView的事件(我遇到了这个库[ASScreenRecorder-master],但当我尝试使用它时它显示了许多错误以 swift )或任何其他方式记录正在显示一些动画(如落雪和图像幻灯片放映)的 UIView ?我希望将它们录制为单个视频并将它们保存到图库中。我四处寻找一些解决方案,但我仍然无法记录 View 。请帮忙。提前致谢。

func start() {
    let sharedRecorder = RPScreenRecorder.shared()

    // Do nothing if screen recording is not available
    guard sharedRecorder.isAvailable else { return }

    // Stop previous recording if necessary
    if sharedRecorder.isRecording {
        stopScreenRecording()
    }

    print("Starting screen recording")

    // Register as the recorder's delegate to handle errors.
    sharedRecorder.delegate = self

    // Start recording
    if #available(iOS 10.0, *) {
        #if os(iOS)
            sharedRecorder.isMicrophoneEnabled = true
            //sharedRecorder.isCameraEnabled = true // fixme
        #endif

        sharedRecorder.startRecording { [unowned self] error in
            if let error = error as? NSError, error.code != RPRecordingErrorCode.userDeclined.rawValue {
                print(error.localizedDescription)
                // Show alert
                return
            }
        }
    } else {
        // Fallback on earlier versions
        sharedRecorder.startRecording(withMicrophoneEnabled: true) { error in
            if let error = error as? NSError, error.code != RPRecordingErrorCode.userDeclined.rawValue {
                print(error.localizedDescription)
                // Show alert
                return
            }
        }
    }
}

最佳答案

不幸的是,您当前无法记录特定的 UIView。您可以使用 ReplayKit 录制整个屏幕,但我知道这不是您想要的。

其他想法:

记录“整个屏幕”,但尝试裁剪到 UIView。 (参见this tutorial)。在您的应用程序中考虑一种记录整个屏幕的方法 - 也许将 UIView 扩展到屏幕边界。

尝试查看其中一些 Github 文件:

File1

File2

File3

关于ios - 在iOS swift中查看录音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45583997/

相关文章:

iphone - 什么时候放入 viewWillAppear,什么时候放入 viewDidLoad?

java - 如何有效地划分测试用例以在使用 appium 的移动应用程序中自动化它们

iOS Swift EXC_BAD_ACCESS 代码2 SearchTextField(UITextField 子类)

Swift: guard let 和 where - 优先级

ios - 缓存图像以供离线使用 SDWebImage

ios - SwiftUI 中 $varName 和 _varName 有什么区别

iPhone .htaccess 重定向循环

iphone - 如何将选择器声明为属性iOS,接下来如何使用我的属性?

ios - 无法在左侧显示长长的 collectionviewcell,在右侧显示小单元格

swift - 当某些协议(protocol)函数更改其签名时,我可以强制编译器失败吗?