gpt4 book ai didi

ios - 即使更改了 View Controller ,相机仍然可以正常工作

转载 作者:行者123 更新时间:2023-11-29 12:36:16 26 4
gpt4 key购买 nike

我将 zxing 集成到我的应用程序中,在我的应用程序中,我有两个选项卡。一个是 history ,另一个是 scan 。问题是当我移动到历史选项卡时,只要相机面对条形码,相机仍然会扫描。我不知道如何在更改 View 时暂停相机。

这是我在 View 中为扫描 View Controller 加载的内容。

 self.capture = [[ZXCapture alloc] init];
self.capture.camera = self.capture.back;

self.capture.focusMode = AVCaptureFocusModeContinuousAutoFocus;
self.capture.rotation = 90.0f;

self.capture.layer.frame = self.view.bounds;
[self.view.layer addSublayer:self.capture.layer];

[self.view bringSubviewToFront:self.scanRectView];
[self.view bringSubviewToFront:self.decodedLabel];

有人能告诉我如何在 View 更改后关闭相机吗?

最佳答案

一旦 View 发生变化,我调用了以下方法来停止相机功能。

-(void)viewDidDisappear:(BOOL)animated{

[super viewDidDisappear:animated];

[self.view.layer removeFromSuperlayer];
self.view = nil;
self.capture=nil;
[self.capture.layer removeFromSuperlayer];

现在可以了。

关于ios - 即使更改了 View Controller ,相机仍然可以正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26247002/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com