使用图像选择器控制器,应用程序在iOS 10中随机崩溃

时间:2017-08-02 16:30:25

标签: ios objective-c ipad xcode8

我正在创建一个有100多个问题的iPad应用。用户可以获得每个问题的安全性,并为每个问题拍照。当我在ios 9中运行该应用程序时,它工作正常,但当项目运行到iOS 10时,应用程序崩溃(当用户拍摄超过30张图像时)。我找不到任何解决方案。 这是我的示例代码....

-(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;

}

此外,我转换采摘图像。任何人都可以帮助我吗?这对我很有帮助。还有一件事,当我将项目运行到模拟器中时,它不会崩溃。我正在获得控制台部分 - &gt;通讯错误:{count = 1,contents =     “XPCErrorDescription”=&gt; {length = 22,contents =“连接中断”}

1 个答案:

答案 0 :(得分:0)

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

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

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

          // your code

        });

    }