Ios 处理此错误的最佳方法是什么?[AVCaptureFigVideoDevice SetTorchModelWithLevel:错误:]:发送到实例的选择器无法识别
如果我的torch应用程序不支持LED调光,我正在尝试关闭该应用程序中的图像Ios 处理此错误的最佳方法是什么?[AVCaptureFigVideoDevice SetTorchModelWithLevel:错误:]:发送到实例的选择器无法识别,ios,objective-c,flashlight,avcapturedevice,respondstoselector,Ios,Objective C,Flashlight,Avcapturedevice,Respondstoselector,如果我的torch应用程序不支持LED调光,我正在尝试关闭该应用程序中的图像 NSError* outError; BOOL success = [device setTorchModeOnWithLevel:brightnessLevel error:&outError]; if(!success){ [self.lightDialIndicator setHidden: YES]; self.ligh
NSError* outError;
BOOL success = [device setTorchModeOnWithLevel:brightnessLevel error:&outError];
if(!success){
[self.lightDialIndicator setHidden: YES];
self.lightDial.image = [UIImage imageNamed:@"light_dial_disabled.png"];
}
但是我的应用程序由于以下错误而崩溃
[AVCaptureFigVideoDevice setTorchModeOnWithLevel:error:]: unrecognized selector sent to instance 0x73ad460
当设备不允许我使用
setTorchModeOnWithLevel
时,有没有更好的/有效的检测方法?首先,setTorchModeOnWithLevel
是AVCaptureDevice
类的一个属性
其次,如果您想测试类是否能够响应您正在调用的某个选择器,可以使用以下方法:
BOOL isSuccessful = NO;
if ([device respondsToSelector:@selector(setTorchModeOnWithLevel:error:)]) {
NSError* outError;
isSuccessful = [device setTorchModeOnWithLevel:brightnessLevel error:&outError];
}
if (!isSuccessful) {
[self.lightDialIndicator setHidden: YES];
self.lightDial.image = [UIImage imageNamed:@"light_dial_disabled.png"];
}
在示例中,您没有说明如何实例化设备
,但这适用于您不确定其是否具有特定方法的任何类