2

我曾在 iPhone 和 iPad 上使用过 Zbar,它可以正常工作,没有任何问题,但在 iPad 的横向模式下却不行。当我ZBarReaderViewController在 iPad 中以横向模式显示弹出框时,视图会发生 90 度偏移,如下图所示,

横向 Zbar

包放在桌子上的地方,图像是用 iPad 在横向模式下拍摄的。我希望包的图像不那么移动。

我已经尝试设置supportedOrientationsMask

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

但它没有以正确的方向显示,而是偏移了 90 度。有人可以帮我解决这个问题吗?非常感谢任何及时的帮助。谢谢。

4

2 回答 2

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);
}
于 2013-03-01T06:34:20.530 回答
1

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

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

viewDidLoad包含 ZBarReaderView 的 ViewController 的方法中。

于 2013-06-24T20:25:54.920 回答