2013-12-10 88 views
1

我想捕获图像并将其保存在imageview中。以下是代码。IOS图像捕获并保存到UIImageView

- (void)imagePickerController:(UIImagePickerController *)picker 
     didFinishPickingImage:(UIImage *)image 
        editingInfo:(NSDictionary *)editingInfo 
{ 
    NSLog(@"Hello"); 
    [picker dismissModalViewControllerAnimated:YES]; 
    [_Image setImage:image]; 
} 

- (IBAction)Capture:(UIButton *)sender { 
     UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; 
     cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera; 
     [self presentViewController: cameraUI animated: YES completion:nil]; 
} 

问题是imagepickercontroller根本没有被调用!我的.h声明是

@interface AikyaViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate> 

我可以让相机捕捉图像,但图像没有保存在我的imageview中。事实上它并没有进入该功能本身,因为它没有NSlogging。

我是否应该链接故事板中的任何内容或任何代表初始化我是否缺少? Plz引导相同。

+0

检查我的编辑答案 – Ilario

回答

2

imagePickerController:didFinishPickingImage:editingInfo:已被弃用

变化是法:

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

NSLog(@"done"); 

[picker dismissViewControllerAnimated:YES completion:Nil]; 

[image setImage:[info objectForKey:@"UIImagePickerControllerEditedImage"]]; 

} 

,并尝试改变:

- (IBAction)Capture:(UIButton *)sender { 
    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; 

    [cameraUI setDelegate:self]; 

    [cameraUI setAllowsEditing:YES]; 

    cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera; 
    [self presentViewController: cameraUI animated: YES completion:nil]; 
    } 
+0

改变,但仍是功能imagepickercontroller没有被一切都叫! – bharath

+0

感谢队友,让它工作! – bharath

+0

@bharath你的欢迎男人! – Ilario

相关问题