【发布时间】:2018-05-12 14:12:55
【问题描述】:
我看到多年来有 869 个问题询问如何解决此错误。我试图理解的是这个消息的根本原因。 869 道题中的每道题都不一样。包括这个。我正在更新 Apple 资源 The AVCamera 代码中的一些代码,以便与 iOS11 一起使用。对象-c。 在这种情况下返回此错误的行是
[stillImageOutput setOutputSettings:outputSettings];
但是,我真正需要的是了解这个错误的根本原因是什么。不仅在这种情况下,而且在大多数情况下。 我第一次把这个项目放在一起是在2014年,当然从那以后更新了十几次,所以有很多Depreciated语句。我现在已经降到了 8 次折旧,但是我弹出了三个错误。这就是其中之一。两个 NO 可见接口,一个 No known 类。
//AVCaptureStillImageOutput *stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
AVCapturePhotoOutput *stillImageOutput = [[AVCapturePhotoOutput alloc] init];
if ([session canAddOutput:stillImageOutput])
{
// [stillImageOutput setOutputSettings:@{AVVideoCodecKey : AVVideoCodecTypeJPEG}];
NSDictionary *outputSettings = @{ AVVideoCodecKey : AVVideoCodecTypeJPEG};
[stillImageOutput setOutputSettings:outputSettings];
[session addOutput:stillImageOutput];
[self setStillImageOutput:stillImageOutput];
}
});
【问题讨论】:
-
Apple 有时会像其他人一样更改 API。首先,他们将某些方法甚至类标记为已弃用:您仍然可以使用它们,但不建议这样做,因为最终(通常在几年内)已弃用的方法/类将被删除。如果您必须支持旧代码,则可以使用旧 SDK 或重构代码。