当我使用 UIImagePickerController 拍照时,屏幕上显示的图片多于屏幕上可见的图片......我怎样才能拍照/裁剪它,以便它与我在屏幕上看到的完全一样?
编辑:我将添加代码,以指定我的问题:
- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
imagePickerController.showsCameraControls = NO;
imagePickerController.allowsEditing = YES;
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
[[NSBundle mainBundle] loadNibNamed:@"OverlayView" owner:self options:nil];
self.overlayView.frame = imagePickerController.cameraOverlayView.frame;
imagePickerController.cameraOverlayView = self.overlayView;
//self.overlayView = nil;
self.overlayImage.image = self.imageView.image;
self.overlayImage.alpha = 0.5;
UISlider *slider=[[UISlider alloc]initWithFrame:CGRectMake(60, 80, 200, 30)];
[slider setMaximumValue:1.0];
[slider setMinimumValue:0.0];
[slider setValue:0.5];
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
if (self.working == TRUE)
{
[imagePickerController.cameraOverlayView addSubview:self.overlayImage];
[imagePickerController.cameraOverlayView addSubview:slider];
}
}
self.imagePickerController = imagePickerController;
[self presentViewController:self.imagePickerController animated:YES completion:nil];
}
didFinishPickingMediaWithInfo:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissViewControllerAnimated:YES completion:NULL];
//this works, image is displayed
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
//this doesn't work, image is nil
UIImage *image = [info objecyForKey:UIImagePickerControllerEditedImage];
[self.imageView setImage:image];
self.working = TRUE;
self.imagePickerController = nil;
//[self dismissViewControllerAnimated:YES completion:NULL];
}
我可以在什么时候使用 UIImagePickerControllerEditedImageimagePickerController.showsCameraControls = NO;
吗?