UIimagePicker和应用程序冻结!

时间:2011-04-30 10:08:44

标签: ios4 uiimagepickercontroller

我正在尝试用相机拍照,但在拍下照片或取消imagePickerView后,我的应用程序将被冻结,没有任何错误报告或BAD_ACCESS或崩溃! jut freeze !!!!这是我的代码:

    -(IBAction)takePic {

    if ([UIImagePickerController isSourceTypeAvailable:CAMERASUPPROT]) {

        USImage.hidden = YES;
        ipc = [[UIImagePickerController alloc]init];

        ipc.delegate = self;
        ipc.sourceType = UIImagePickerControllerSourceTypeCamera; 
        ipc.cameraOverlayView = maskImage;
        ipc.delegate = self;
        [self.view addSubview:MaskArea];
        [self presentModalViewController:ipc animated:YES];
        TAKENPHOTO.image = nil;
        [ipc release];

  } else {

        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Your Device Doesn't Support Camera" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }

}

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

    TAKENPHOTO.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [picker dismissModalViewControllerAnimated:YES];

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { 

    [picker dismissModalViewControllerAnimated:YES];
}

1 个答案:

答案 0 :(得分:1)

假设[self.view addSubview:MaskArea];它是一个UIView所以,我认为问题是这一行,删除它然后再试一次!