2010-11-10 77 views
3

我正在使用UIImagepickerController從相機拍攝照片..我通過使用cameraoverlayview屬性在相機視圖上使用我自己的視圖...我想在用戶單擊自定義視圖中的按鈕時從相機拍攝照片。 ..我現在用的是下面的代碼使用UIImagepickerController cameraoverlayview拍照?

- (void)viewDidLoad { 

imagePickerController = [[UIImagePickerController alloc] init]; 
    imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 
    [self presentModalViewController:imagePickerController animated:YES]; 
    imagePickerController.showsCameraControls=NO; 

imagePickerController.cameraOverlayView = self.customView; 

} 

- (IBAction) takePicture 
{ 
    [imagePickerController takePicture]; 
} 

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

    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; 

    imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; 

[picker dismissModalViewControllerAnimated:YES]; 

} 

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker 
{ 
    [self dismissModalViewControllerAnimated:YES]; 
} 

但是當我運行這段代碼它給我的錯誤

ERROR: FigCreateCGImageFromJPEG returned -12905. Input (null) was 773625 bytes.

,我也得到了內存使用2級警告,然後平1

沒有圖像是d顯示在imageView ..任何人都可以幫助我,我可能會做錯什麼? 順便說一句我使用的iPhone 3G上安裝的iOS4.1

+0

不確定,但看看UIImage與UIImageView。我懷疑它可能與你的'[objectforKey:...]'調用有關。 – Moshe 2010-11-10 05:29:19

+0

其實didFinishPickingMediaWithInfo甚至沒有被調用..我已經包括它的代表 – hemant 2010-11-10 06:40:32

回答

1

UIImagePickerControllerOriginalImage是一個符號(一個NSString *常數),你不能承擔它的價值。按原樣使用,不含引號。除此之外,如果您正確保留並創建了選取器和圖像視圖,它應該可以工作。

相關問題