2

当我按下按钮时,相机会打开,但如果我按下取消,或者在我拍照并按下 USE 后,相机就会卡住。我想解散,移除相机并将图像用于我的 ImageView。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    scrtImg.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [picker2.view removeFromSuperview];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [picker2.view removeFromSuperview];
}


- (IBAction)openCamera:(id)sender
{    
    picker2 = [[UIImagePickerController alloc]init];
    picker2.delegate = self;
    [picker2 setSourceType:UIImagePickerControllerSourceTypeCamera];
    [self addSubview:picker2.view];
    [picker2 release];  
}

如果我在 ViewController 上使用此代码,效果很好,但在 UIView 中它不起作用。帮帮我,我需要从 UIView 打开相机,并在 UIView 中使用图像。谢谢

4

1 回答 1

0

一旦在窗口中添加 UIView 然后尝试。它可能会起作用。

于 2013-04-30T09:29:28.460 回答