iphone - 拍照时崩溃/内存警告 - iPhone

标签 iphone memory crash camera

我收到内存警告,并且在使用 iPhone 拍照期间应用程序崩溃。不知道如何解决这个问题,因为打开相机的代码可以工作 - 并且拍摄照片后的代码可以工作,但错误出现在相机拍摄应用程序的图片部分......

我正在像这样启动相机:

imagePicker = [[UIImagePickerController alloc] init];

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
{
    [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
}
else 
{
    [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}

if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) {
            imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
} else if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) {
            imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
}

imagePicker.delegate = self;

[self presentModalViewController:imagePicker animated:YES];

我收到“收到内存警告”。就在 Recorder_SourceStarted 和 AVCaptureDeviceDidStartRunningNotification 之前。

然后,在应用程序崩溃之前,我会得到 Recorder_DidStartPreviewing、Recorder_FlashStateChanged、Recorder_DidStartFocusOperation、Recorder_DidCompleteFocusOperation、Recorder_FlashStateChanged、Recorder_WillCapturePhoto、Recorder_DidCapturePhoto 和 Recorder_PhotoStillImageSampleBufferReady。

Recorder_PhotoStillImageSampleBufferReady 是我在应用程序崩溃之前收到的最后一条通知。它没有到达 _UIImagePickerControllerUserDidCaptureItem ,此时应用程序开始运行我再次编写的代码。

有时它不会崩溃......我收到内存警告并且应用程序继续正常工作,但是由于这个内存警告,可能会发生崩溃,我在测试中遇到崩溃,所以我想找出导致此问题的原因并修复它。

任何帮助都会很棒!谢谢!

最佳答案

我在应用程序中分配 tableViews(不是因为它使用 ARC 而解除分配),显然在调用 alloc tableViews 之后, try catch 图片会导致内存崩溃。当用户需要查看表格而不是每次请求表格 View 时都进行分配时,我将其更改为打开和关闭表格 View 上的 .hidden 属性,现在应用程序在拍照时永远不会崩溃。有时还有内存警告,但从来没有崩溃过,而且我拍照时经常根本没有内存警告。

关于iphone - 拍照时崩溃/内存警告 - iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15556795/

相关文章:

c++ - 在全局/函数范围内声明变量。堆栈差异?

c++ - 数组如何在 C/C++ 中内部工作

iphone - 如何避免在iPhone应用程序中泄漏?

ipad - Uiwebview 使应用程序崩溃

iphone - 核心数据 : Setting Entity. 属性、类型问题

iphone - iOS 在按钮点击时添加 View

javascript - 垃圾收集和 JavaScript "delete": Is this overkill/obfuscation, 还是一个好的做法?

iOS崩溃报告 "unexpected start state"异常?

iphone - 无法执行转接

iphone - 如何向 ASIHttpRequest 添加 GET 参数?