我在子视图(280x240)上使用UIImagePickerController。我使用这段代码:
imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setVideoQuality:UIImagePickerControllerQualityType640x480];
[imagePicker setDelegate:self];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setCameraFlashMode:UIImagePickerControllerCameraFlashModeAuto];
[imagePicker setShowsCameraControls:NO];
[imagePicker viewWillAppear:YES]; // trickery to make it show
[imagePicker viewDidAppear:YES];
[self.borderView addSubview:imagePicker.view]; //borderView size is 280x240
我正在拍摄图像选取器原始图像,我想只拍摄子视图(borderView)上显示的区域。我该怎么办?
答案 0 :(得分:0)
try this.
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePicker = [[MyImagePickerController alloc]init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
imagePicker.showsCameraControls=YES;
[self presentViewController:imagePicker animated:YES completion:^{
NSLog(@"Completed");
}];
and then call delegate method of UIImagePickerController
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
capturedPicImageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[capturedPicImageView sizeToFit];
capturedPicImageView.contentMode = UIViewContentModeScaleAspectFill;
capturedPicImageView.image = [self resizeAndStoreImages:capturedPicImageView.image];
UIImageWriteToSavedPhotosAlbum(capturedPicImageView.image, nil, nil, nil);
}