iPhone检查是否存在AVCaptureSession

iPhone检查是否存在AVCaptureSession

本文介绍了iPhone检查是否存在AVCaptureSession类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经集成了一个使用AVCaptureSession从相机中捕获照片的库。由于AVCaptureSession仅适用于 4设备,我想禁用此功能旧设备的集成功能。

I have integrated a library that uses AVCaptureSession to capture a photo from the camera. As the AVCaptureSession is only available on iOS 4 devices, I want to disable this integrated functionality for older devices.

我知道应该通过弱链接AVFoundation Framework并检查函数是否存在来完成。弱连接很容易,但我应该检查哪些功能存在? AVCaptureSession是一个类而不是函数。

I know that it should be done by weak-linking the AVFoundation Framework and checking for function existence. Weak-linking is easy to do, but which function should I check for existence here? AVCaptureSession is a class and not a function.

是否有一些示例代码可用?

Are there some sample code available?

推荐答案

我认为你正在寻找 NSClassFromString

Class NSClassFromString ( NSString *aClassName );

然后您可以使用以下内容保护该类的使用:

You can then guard usage of that class with something like this:

if (NSClassFromString(@"AVCaptureSession")) {
    ...
}

这篇关于iPhone检查是否存在AVCaptureSession类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 17:31