Pregunta

hello Everyone I am facing an issue. In my app I want to crop an area of image taken from camera. Therefore, I am using UIImagePickerController & it's cameraOverlayView.

The problem is that on iPhone 4S,iPad,iPod - "status bar" is not transparent. On 2nd iPad, "status bar" in camera is transparent. I do not know how to access status bar of UIImagePickerController?

In my code I do some height calculation, in case of transparency I wrongly subtract extra size. And I cannot figure out hot to get size of image inside "shooting area".

Here is some code:

+(CGFloat) statusBarYSize
{
    CGSize statusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;
    return MIN(statusBarSize.width, statusBarSize.height);
}

+(CGRect)maxRectForPicker:(UIImagePickerController*)picker
{
    CGRect maxFrame = picker.cameraOverlayView.frame;
#warning @"Check that coefficient is equal to such value everywhere...)"
    if (!picker.toolbar.translucent) 
        maxFrame.size.height -=([self statusBarYSize]*2.5); // If transparent should not be subtracted!
    return maxFrame;
}

Here are links on images:

iPhone's image. Camera has the size full screen - status bar.

https://www.dropbox.com/s/7b405h5cavrf819/CorrectSubstraction.jpg

IPad's image. Camera occupies the whole screen.

https://www.dropbox.com/s/7rekl8xen1z3s9b/ShouldNotSubstract.jpg

Many thanks in advance. Siarhei

¿Fue útil?

Solución

I came to solution in the following way: Instead of trying to figure out properties. I calculate aspect ratio of image from camera, and aspect ratio of screen. After that I rescale image keeping native aspect ration. It allows me to find a height of camera's standard bar.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top