程序不响应了,说明你的程序某个地方出了问题。你自己debug后也找到了问题的根源在UIImageJPEGRepresentation这个方法上。那你就找一下,为什么调用这个方法的时候就出错了。
可能的原因:
在UIImagePickerController的代理方法中拿到刚刚通过相机拍下的照片,在这个地方请确定你拿到的UIImage对象不是一个nil. 还有就是确保你的imagePicker没有提前释放。如上,只是一些猜测,建议还是贴出部分代码看看。

解决方案 »

  1.   

    -(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
        if ([[info objectForKey:UIImagePickerControllerMediaType] isEqualToString:@"public.image"]) //图片
        {
            //获取拍照的图片并压缩
            UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

    //保存到close plus相册
    [self performSelectorInBackground:@selector(saveImage:) withObject:image];

    if (_bFromActive)
    {
                // UIImage* newImage = [Tool saveBitImage:image];
    NSData *imageData = [Tool scaleImage:image];
    [_delegate didFinishImagePickerWithImage:nil andScaleImageData:imageData];
    [self dismissViewControllerAnimated:YES completion:^{
    ;
    }];
    }
    else
    {
    NSData *data =[Tool scaleImage:image];
    IdeaViewController *ideaViewCtrl = [[IdeaViewController alloc] initwithImageData:data type:Photo];
    [self.navigationController.navigationBar setHidden:NO];
    [self.navigationController pushViewController:ideaViewCtrl animated:YES];
    }
        }红色部分是被挂的部分,跟踪了进去
    主要是如下部分
    CGSize itemSizeSmall = CGSizeMake(iwidthSmall, iheightSmall);
            UIGraphicsBeginImageContext(itemSizeSmall);
            
            CGRect imageRectSmall = CGRectMake(0.0f, 0.0f, itemSizeSmall.width+2, itemSizeSmall.height+2);  //长和宽都增加2个像素,防止有些图片绘制旁边出现白线
    NSLog(@"before drawInRect!!!!,%@,%f,%f",image,imageRectSmall.size.width,imageRectSmall.size.height);
            [image drawInRect:imageRectSmall];
    NSLog(@"after drawInRect!!!!");
            UIImage *scaleImage = UIGraphicsGetImageFromCurrentImageContext();

    dataImage = UIImageJPEGRepresentation(scaleImage,0.62);        [image drawInRect:imageRectSmall]; 后代码就被走了,程序就这么给空闲着了。。
      

  2.   


    在这句UIGraphicsGetImageFromCurrentImageContext();后面,UIImageJPEGRepresentation之前补上这句试试:UIGraphicsEndImageContext();
      

  3.   


    在这句UIGraphicsGetImageFromCurrentImageContext();后面,UIImageJPEGRepresentation之前补上这句试试:UIGraphicsEndImageContext();NSLog(@"after drawInRect!!!!"); 这句都没有打印出来,UIGraphicsGetImageFromCurrentImageContext() 都还没执行呢。。