2017-08-02 53 views
0

我正在创建一个超过100个问题的iPad应用程序。用户获取answare的每个问题,并为每个问题拍照。当我在ios 9中运行thease应用程序时它工作正常,但是当项目运行到iOS 10时,应用程序崩溃(当用户拍摄超过30张图像时)。我找不到任何解决方案。 这里是我的示例代码....使用图像选择控制器该应用程序在iOS 10中随机崩溃

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInf{ 


isImageChanged = YES; 
[self.btnSelectImage setImage:image forState:UIControlStateNormal]; 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) 
{ 
    //Edited by Sarfaraj on 10th Sept, 2014 == > 

    [popOverSelectImage2 dismissPopoverAnimated:YES]; 

    [self.captionView removeFromSuperview]; 

    UIViewController *vc = [[UIViewController alloc]init]; 

    //  vc.view = self.captionView; 

    vc.view.frame = self.captionView.frame; 

    [vc.view addSubview: self.captionView]; 



    /* 

    [vc.view setFrame:self.captionView.frame]; 

    for (UIView *object in self.captionView.subviews) { 



    [vc.view addSubview:object]; 

    } 

    */ 

    // < == 

    [popOverSelectImage dismissPopoverAnimated:NO]; 

    popOverSelectImage = [[UIPopoverController alloc] initWithContentViewController:vc]; 


    [popOverSelectImage setPopoverContentSize:CGSizeMake(self.captionView.frame.size.width, self.captionView.frame.size.height) animated:NO]; 



    //popOverSelectImage.contentViewController = vc; 


    [popOverSelectImage presentPopoverFromRect:currBtnRectForPopoverImage inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:NO]; 
} 
else 
{ 
    [self dismissModalViewControllerAnimated:YES]; 
} 

imageToSave = image; 

}

而且我转换采摘图像。任何人都可以帮助我吗?这对我很有帮助。还有一件事,当我运行项目到模拟器,它不会崩溃。并且控制台部分我越来越 - >通信错误:{count = 1,contents = “XPCErrorDescription”=> {length = 22,contents =“连接中断”}

+1

笏不会崩溃说? –

+0

我只有记忆警告进入控制台部分,当我采取超过30个图像。但iOS 9,我没有得到任何崩溃。为什么? – Abir

+0

您是否在info.plist文件中添加了照片库访问隐私? –

回答

0

我认为使用调度可以解决这个问题,请尝试使用

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{ 

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 

      // your code 

     }); 

    } 
+0

ami我使用此代码到imagepicker控制器委托方法? @z – Abir

+0

我也使用 [[NSOperationQueue mainQueue] addOperationWithBlock:^ {image02 = {self useImage:image]; [self.btnSelectImage setImage:[UIImage imageWithData:imageData] forState:UIControlStateNormal]; self.imagePicker = nil; }]; 但没有任何事情发生在ios 10. – Abir

+0

是的请..看到编辑代码 –