我有一个应用程序可以拍一些照片。我的整个应用程序都是基于AVCam 2010的示例代码。我已经把它弄得一团糟,但到目前为止,我还不知道如何正确地释放相机视图,从而释放相机会话.
我想做的就是:
当我第二次按下viewController时,会话丢失了,预览不可用,捕获也不可用。我出版了github上的完整示例代码。
我解决这个问题的方法是根本不发布相机,所以相机视图控制器就像一个单例,我认为这是而不是的正确方式。而且,有了这种行为,当应用程序转到后台(例如,电话)时,我无法找到支持照相机的方法。
,请通知。我该如何破坏摄像机的功能?这样做重要吗?
发布于 2011-11-07 08:46:19
我向AVCamCaptureManager添加了以下消息
- (void) destroySession {
if ([delegate respondsToSelector:@selector(captureManagerSessionWillEnd:)]) {
[delegate captureManagerSessionWillEnd:self];
}
// remove the device inputs
[session removeInput:[self videoInput]];
[session removeInput:[self audioInput]];
// release
[session release];
// remove AVCamRecorder
[recorder release];
if ([delegate respondsToSelector:@selector(captureManagerSessionEnded:)]) {
[delegate captureManagerSessionEnded:self];
}
}当拿着相机的viewController靠近时,我打电话给viewController(在我的例子中,它是-closeCamera: of AVCamViewController)。
对于完整的工作示例,欢迎下载AVCam-CameraReleaseTest on github.com
发布于 2011-10-13 12:36:10
G
我想这也许能帮你看看。
http://red-glasses.com/index.php/tutorials/ios4-take-photos-with-live-video-preview-using-avfoundation/
https://stackoverflow.com/questions/7752931
复制相似问题