请帮助.... 我找不到答案,必须有一个简单的解决方案。
我允许用户使用UIImagePickerController在iPhone相机上拍照 - 我想用我设置为cameraOverlayView的UIView保存这张照片。
这怎么可能?
由于
挖洞
答案 0 :(得分:0)
-(void) viewDidAppear:(BOOL)animated{
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.wantsFullScreenLayout =YES;
picker.cameraOverlayView = overlayView;
[self presentModalViewController:picker animated:NO];
[self.view bringSubviewToFront:overlayView];
[picker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
NSData* imageData = UIImageJPEGRepresentation(image, 0.1);
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"Image%i.jpg",i]];
[imageData writeToFile:fullPathToFile atomically:NO];
i++;
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker1 {
[picker1 dismissModalViewControllerAnimated:NO];
overlayView.hidden = YES;
}
-(void) takepicture:(id) sender{
[self.picker takePicture];
}