2017-08-02 51 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

是的請..看到編輯代碼 –