2014-02-24 112 views
0

我有AVCaptureVideoPreviewLayer的问题。我创建它是这样的:AVCaptureVideoPreviewLayer崩溃应用程序在发布

self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session]; 

会话是我的AVCaptureSession对象。它已经被初始化了。当我从视图控制器弹出我的应用程序崩溃。无论如何,我甚至不会使用这个vatiable,我也会崩溃。我得到EXC_BAD_ACCESS代码= 1 ;. self.previewLayer是我的类对象。我声明是在我的课堂上,然后使用retain和nonatomic和@synthesize来设置它的属性。我使用RosyWritter的代码,唯一不同的是我使用AVCaptureVideoPreviewLayer。似乎我释放这个对象有问题。有人可以告诉我我做错了什么吗?

编辑

我终于解决了。它发生,我不注销videoOut代表:)

PS:我使用自动引用计数

+1

崩溃线程的栈看起来像什么? –

+0

它看起来像这样:http://postimg.org/image/rig4m7qv5/ – AYMADA

+1

如果您将线程视图底部的滑块移动到右侧,它将显示堆栈中的所有帧。这会更有帮助。但是,由于顶部框架是'obj_msgSend',我建议在构建方案中打开僵尸并运行它。它很可能会在调试控制台中为您提供更有用的消息。 –

回答

1

能否请您提供一下,您是如何访问AVCaptureVideoPreviewLayer一些更多的细节。如果有,请粘贴崩溃日志。

请尝试使用以下代码块的代码模拟。

if ([self captureManager] == nil) { 
     captureManager = [[AVCamCaptureManager alloc] init]; 
     captureManager.delegate = self; 



     if ([[self captureManager] setupSession] && _captureVideoPreviewLayer == nil) { 
      // Create video preview layer and add it to the UI 
      _captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:[[self captureManager] session]];  



      if ([_captureVideoPreviewLayer isOrientationSupported]) { 
       [_captureVideoPreviewLayer setOrientation:AVCaptureVideoOrientationPortrait]; 
      } 

      [_captureVideoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill]; 


      // Start the session. This is done asychronously since -startRunning doesn't return until the session is running. 
      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 
       [[[self captureManager] session] startRunning]; 
      }); 
     } 
    } 

希望它有帮助。请检查并告诉我们是否需要使用其他解决方案。

+0

我编辑我的帖子并添加我的代码。你能检查它吗? – AYMADA

相关问题