2012-09-10 62 views
2

當我按下按鈕,相機打開,但如果我按取消,或者在我拍照並按USE後,相機卡住了。我想解僱,刪除相機,併爲我的ImageView使用圖像。UIView UIImagePickerController

- (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中使用USE圖像。謝謝

回答

0

一旦在窗口中添加UIView,然後嘗試。它可能工作。