ZBar适用于iPad的横向定位

时间:2012-11-15 09:12:16

标签: ios uiinterfaceorientation zbar-sdk

我曾经在iPhone和iPad上使用Zbar,它没有任何问题,但没有iPad中的横向模式。当我在横向模式下使用弹出模式在iPad中显示ZBarReaderViewController时,视图会移动90度,如下图所示,

Zbar in landscape

袋子放在桌子上,用横向模式的iPad拍摄图像。我希望袋子图像没有移动。

我已尝试将supportedOrientationsMask设为

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

但它没有以正确的方向显示,而是90度移位。有人可以帮我解决这个问题吗?任何及时的帮助都会更受赞赏。感谢。

2 个答案:

答案 0 :(得分:3)

我有几乎相同的问题,我通过添加以下代码解决了这个问题。我的应用仅支持横向广告:

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);
}

答案 1 :(得分:1)

这个解决方案的问题是只修复了问题的可视部分。用户看到正确的方向,但是ZBarReader仍然“看到”相同的图像,因为您正在转换预览图像。有效的是:

[self.readerView willRotateToInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation] duration:0];

在包含ZBarReaderView的ViewController的viewDidLoad方法中。