Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在使用拍照的时候崩了 #62

Closed
lwy121810 opened this issue Jun 14, 2016 · 7 comments
Closed

在使用拍照的时候崩了 #62

lwy121810 opened this issue Jun 14, 2016 · 7 comments

Comments

@lwy121810
Copy link

我是在使用pad真机运行的时候, 点击拍照上面第二个闪电按钮的时候崩溃的,崩溃在

  • (void) closeFlashlight:(UIButton )sender{
    // self.device.torchMode == AVCaptureTorchModeOff 判断
    [self flashLightModel:^{
    [self.device setTorchMode:AVCaptureTorchModeOff];//这一行
    }];
    }
    崩溃信息为
    相册Demo[12257:5168757] *
    * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureVideoDevice setTorchMode:] - the passed torchMode 0 is not supported by the device. Use -isTorchModeSupported: to discover valid torch modes.'
    *** First throw call stack:
    (0x1812f9900 0x180967f80 0x187584da0 0x100097664 0x100097290 0x1000975d4 0x186023e50 0x186023dcc 0x18600ba88 0x1860236e4 0x186023314 0x18601be30 0x185fec4cc 0x185fea794 0x1812b0efc 0x1812b0990 0x1812ae690 0x1811dd680 0x1826ec088 0x186054d90 0x1000857f0 0x180d7e8b8)
    libc++abi.dylib: terminating with uncaught exception of type NSException
@MakeZL
Copy link
Owner

MakeZL commented Jun 14, 2016

@lwy121810 你好,你可以看下最新代码看看效果,我换了这种方式来处理。

AVCaptureDevice* device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[device lockForConfiguration:nil]; //you must lock before setting torch mode
[device setTorchMode:isOn ? AVCaptureTorchModeOn : AVCaptureTorchModeOff];
[device unlockForConfiguration];

@lwy121810
Copy link
Author

恩, 我刚刚又下载了一下, 不过还是崩溃

@lwy121810
Copy link
Author

崩溃在- (void) setTorchOn:(BOOL)isOn
{
[self.device lockForConfiguration:nil]; //you must lock before setting torch mode
[self.device setTorchMode:isOn ? AVCaptureTorchModeOn : AVCaptureTorchModeOff];//这一行
[self.device unlockForConfiguration];
}

崩溃信息:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureVideoDevice setTorchMode:] - the passed torchMode 0 is not supported by the device. Use -isTorchModeSupported: to discover valid torch modes.'
*** First throw call stack:
(0x1812f9900 0x180967f80 0x187584da0 0x1000f1cb4 0x1000f1e78 0x1000f192c 0x1000f1ddc 0x186023e50 0x186023dcc 0x18600ba88 0x1860236e4 0x186023314 0x18601be30 0x185fec4cc 0x185fea794 0x1812b0efc 0x1812b0990 0x1812ae690 0x1811dd680 0x1826ec088 0x186054d90 0x10013f168 0x180d7e8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

@MakeZL
Copy link
Owner

MakeZL commented Jun 14, 2016

    if ([self.device isTorchModeSupported:AVCaptureTorchModeOn] ||
        [self.device isTorchModeSupported:AVCaptureTorchModeOff]) {
 ....
}

@lwy121810 我加了一个判断. 麻烦再试下

@lwy121810
Copy link
Author

可以了, 不会蹦了, 不过这样的话上面的闪电按钮有什么用呢?点击好像没什么效果啊?

@MakeZL
Copy link
Owner

MakeZL commented Jun 14, 2016

因为你的设备不支持闪光灯,o(╯□╰)o...

@MakeZL MakeZL closed this as completed Jun 14, 2016
@lwy121810
Copy link
Author

原来如此,现在我看ZLPhoto都是用的<AssetsLibrary/AssetsLibrary.h>这个库 , 不过这个库不是已经被PhotoKit取代了么? 您有没有想过更换为PhotoKit?因为最近在学习您这个库, 谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants