videoMinFrameDuration已弃用 [英] videoMinFrameDuration is Deprecated

查看:970
本文介绍了videoMinFrameDuration已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将Xcode从4.6更新到5.1时`'videoMinnFrameDuration'在ios7中已被弃用

When I have updated Xcode from 4.6 to 5.1 `'videoMinnFrameDuration' is deprecated in ios7

- (void)setFrameRate:(NSInteger)frameRate;
 {
_frameRate = frameRate;

if (_frameRate > 0)
{
    for (AVCaptureConnection *connection in videoOutput.connections)
    {

        if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)])
            connection.videoMinFrameDuration = CMTimeMake(1,_frameRate);


推荐答案

首先,你使用的是过时的版本GPUImage,因为这已经在框架代码中修复了近一年了。更新您的本地框架版本。

For one thing, you're using an outdated version of GPUImage, as this is has been fixed in the framework code for almost a year now. Update your local framework version.

我在GPUImage中解决此问题的方式,因为我仍然需要对旧的iOS版本使用此方法,是禁用相关的弃用检查代码:

The way I address this in GPUImage, since I still need to use this method for old iOS versions, is to disable deprecation checks around the relevant code:

    if ([_inputCamera respondsToSelector:@selector(setActiveVideoMinFrameDuration:)] &&
        [_inputCamera respondsToSelector:@selector(setActiveVideoMaxFrameDuration:)]) {

        NSError *error;
        [_inputCamera lockForConfiguration:&error];
        if (error == nil) {
#if defined(__IPHONE_7_0)
            [_inputCamera setActiveVideoMinFrameDuration:CMTimeMake(1, _frameRate)];
            [_inputCamera setActiveVideoMaxFrameDuration:CMTimeMake(1, _frameRate)];
#endif
        }
        [_inputCamera unlockForConfiguration];

    } else {

        for (AVCaptureConnection *connection in videoOutput.connections)
        {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
            if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)])
                connection.videoMinFrameDuration = CMTimeMake(1, _frameRate);

            if ([connection respondsToSelector:@selector(setVideoMaxFrameDuration:)])
                connection.videoMaxFrameDuration = CMTimeMake(1, _frameRate);
#pragma clang diagnostic pop
        }
    }

如果新属性( activeVideoMinFrameDuration )可用,我们使用它。如果没有,它将回退到现在已弃用的方法。由于我们知道它已被弃用,因此没有必要让编译器向我们发出警告。

If the new property (activeVideoMinFrameDuration) is available, we use that. If not, it falls back to the now-deprecated method. Since we know it's deprecated, there's no need to have the compiler warn us about this.

这篇关于videoMinFrameDuration已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆