经常相机捕捉崩溃应用程序没有任何线索

时间:2017-02-15 12:33:58

标签: ios objective-c camera dismiss

我正在使用UIIMagePicker控制器来捕获图像。相机捕捉在前30到40次拍摄时工作正常,但在大约40次拍摄后它会使应用程序崩溃。我没有收到关于xcode的任何内存警告或崩溃报告。

此问题看起来像内存泄漏,但我已经监控仪器和内存使用不超过60 MB。

来自图库的图片选择不会导致此问题。

enter image description here

我正在使用的代码: -

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

[MBProgressHUD showHUDAddedTo:self.view animated:true];
UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
NSDate *now = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"MMM-dd-yyyy";
[dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
timeFormatter.dateFormat = @"HH:mm a";
[timeFormatter setTimeZone:[NSTimeZone systemTimeZone]];   
NSString *strtime=[NSString stringWithFormat:@"%@\n%@ ",[timeFormatter stringFromDate:now],[dateFormatter stringFromDate:now]];
lblTime.numberOfLines =0;
[lblTime setText:strtime];
[lblTime setHidden:YES];
imgTakenPhoto.image = chosenImage;
[btnCrossOnDentView setHidden:YES];
[btnDoneWithDent setHidden:YES];
App_Delegate.isEdited = YES;
[picker dismissViewControllerAnimated:YES completion: ^{

               dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideAllHUDsForView:self.view animated:true];
imagePickerController = nil;
});   }];
}

3 个答案:

答案 0 :(得分:2)

它是一个iPhone OS问题。我还提交了一份关于这个问题的报告。相同的代码在iPad中运行良好。报告错误并提交您的项目。

答案 1 :(得分:1)

最好的解决方法是,不要使用UIImagePicker for Camera,使用自定义摄像头视图,如WhatsApp,在其上提供一个捕获按钮,以捕获任意数量的图片。

使用AVCapture

这将完全消除打开相机控制器的负担。

答案 2 :(得分:-1)

我还遇到了这个问题我当前的工作申请。这是因为运行应用程序时内存溢出。我在应用程序运行状态中删除了不必要的内存现在我的应用程序正常运行没有任何问题。

相关问题