Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 处理此错误的最佳方法是什么?[AVCaptureFigVideoDevice SetTorchModelWithLevel:错误:]:发送到实例的选择器无法识别_Ios_Objective C_Flashlight_Avcapturedevice_Respondstoselector - Fatal编程技术网

Ios 处理此错误的最佳方法是什么?[AVCaptureFigVideoDevice SetTorchModelWithLevel:错误:]:发送到实例的选择器无法识别

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

如果我的torch应用程序不支持LED调光,我正在尝试关闭该应用程序中的图像

  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"];
}
在示例中,您没有说明如何实例化
设备
,但这适用于您不确定其是否具有特定方法的任何类