質問

I have been reading different answers but havent been able to fix this problem:

On my iPad app, landscape mode, I have a UIImagePickerController to take a picture this picker gets shown inside a UIPopoverController.

The problem is that the image size on the preview and after taking the pic are different

Preview:

image on preview .

After taking the image:

taken pic

here my code for setting the picker and popOver:

BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];

    picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;

    picker.sourceType = hasCamera ? UIImagePickerControllerSourceTypeCamera :    UIImagePickerControllerSourceTypePhotoLibrary;

    picker.modalPresentationStyle = UIModalPresentationFullScreen;

    picker.cameraDevice = UIImagePickerControllerCameraDeviceFront; 
    [picker setShowsCameraControls:FALSE];

    self.companyPopOverController = [[[UIPopoverController alloc] initWithContentViewController:picker] autorelease];

    self.companyPopOverController.passthroughViews=[NSArray arrayWithObject:self.view];
[self.companyPopOverController presentPopoverFromRect:CGRectMake(622, 534, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];

and to show the taken pic:

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

    UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];
    [self.picImage setImage:image];
    [self.companyPopOverController dismissPopoverAnimated:YES];
    self.imageTaken = YES;
}

So how can I make my preview image with the same size as the actual image taken?

thanks!

役に立ちましたか?

解決

I see 2 differences in your sample images: size and a horizontal flip.

The size difference could be because you are setting picker.modalPresentationStyle = UIModalPresentationFullScreen; but then you are displaying it in a smaller popover. I would try and present the picker without a popover and see if it works.

Also, the preview image looks a bit distorted. If you are using Scale To Fill as contentMode for the imageView then I would change it to Aspect Fill.

I don't know where the horizontal flip might come from.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top