Search code examples
iosuiinterfaceorientationzbar-sdk

ZBar for landscape orientation in iPad


I've worked on the Zbar in iPhone and also in iPad, it works fine without any issues, but not with the landscape mode in iPad. When I present the ZBarReaderViewController in iPad with a popover in landscape mode, the view is 90 degree shifted as in the below image,

Zbar in landscape

where the bag is on the table and the image is captured with iPad in landscape mode. I want the bag image not as shifted.

I've already tried setting the supportedOrientationsMask as

reader.supportedOrientationsMask = ZBarOrientationMask(UIInterfaceOrientationLandscapeLeft || UIInterfaceOrientationLandscapeRight);

But its not showing in the correct orientation, but is a 90 degree shifted. Can someone help me solve this issue? Any timely help is much more appreciated. Thanks.


Solution

  • I had almost the same issue, and I got it resolved by adding the below code. My app supports only Landscape orientation:

    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    if (UIDeviceOrientationLandscapeLeft == orientation) {
        //Rotate 90
        reader.cameraViewTransform = CGAffineTransformMakeRotation (3*M_PI/2.0);
    } else if (UIDeviceOrientationLandscapeRight == orientation) {
        //Rotate 270
        reader.cameraViewTransform = CGAffineTransformMakeRotation (M_PI/2.0);
    }