重新打开 AVCaptureSession
我有一个可以拍摄一些照片的应用程序。 我的整个应用程序基于 WWDC 2010 的 AVCam 示例代码。 我已经搞砸了很多,但是,到目前为止,我不知道如何正确释放相机视图,从而释放相机会话......
我想做的就是以下内容:
- 打开相机视图控制器
- 拍一些照片
- 关闭相机视图控制器
- 再次打开它
第二次我推动视图控制器时,会话丢失,预览不可用,捕获也不可用。我已在 github 上发布了完整示例代码。
我解决这个问题的方法是根本不释放相机,因此相机视图控制器充当单例,我认为这不是正确的方法。此外,由于这种行为,当应用程序进入后台(例如打电话)时,我无法找到支持相机的方法。
请提出建议。如何破坏相机会话?这样做重要吗?
I have an application which takes some pictures.
My whole application is based on the AVCam sample code from WWDC 2010.
I've messed with it a lot and yet, up until now I can't figure out how to release the camera view properly which releases the camera session...
All i'm trying to do is the following:
- Open camera view controller
- Take some photos
- Close camera view Controller
- Open it again
The second time I push the viewController the session is lost, preview is not available and capturing is not available as well. I've published full example code on github.
My workaround for the issue was not to release the camera at all so the Camera View Controller acts as a Singleton, which I think is not the right way. moreover, with this behavior I couldn't figure out a way to support camera when application went to the background (phone call for example).
Please advice. How do I destruct the camera session? and is it important to do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已将以下消息添加到
AVCamCaptureManager
中,当持有相机的 viewController 靠近时,我正在调用
destroySession
(在我的示例中为-closeCamera:
AVCamViewController
的 >)。如需完整的工作示例,欢迎您在 github.com 上下载 AVCam-CameraReleaseTest
I've added the following message to
AVCamCaptureManager
I'm calling
destroySession
when the viewController holding the camera get close (on my example it's-closeCamera:
ofAVCamViewController
).For the full working example, you're welcome to download AVCam-CameraReleaseTest on github.com
G
我想这可能会帮助你看看。
http:// red-glasses.com/index.php/tutorials/ios4-take-photos-with-live-video-preview-using-avfoundation/
G
I think that may help you have a look .
http://red-glasses.com/index.php/tutorials/ios4-take-photos-with-live-video-preview-using-avfoundation/