0

有谁知道如何设置 ZBar SDK 的界面方向?我需要它在横向视图而不是纵向视图中工作。我尝试添加[reader shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];,但没有奏效。有任何想法吗?

4

3 回答 3

2

我遇到了同样的问题并简单地解决了!

我只需要打电话:

[reader willRotateToInterfaceOrientation: toInterfaceOrientation duration: duration];

在包含 ZbarReaderView 的视图控制器的 willRotate... 中。

于 2013-04-03T17:49:33.137 回答
2

围绕 ZBarReaderView 创建一个包装类并添加 iOS 6 方法:

-(BOOL) shouldAutorotate
{
    return NO;
}

-(NSUInteger) supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

然后使用您在内置 ZBar 上创建的类,确保将旧的 iOS 5 方法保留在同一个控制器中:

- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscape);
}

并且:

    self.reader.supportedOrientationsMask = ZBarOrientationMask(UIInterfaceOrientationMaskLandscape);

我知道已经很晚了,但我刚刚开始为 iOS 6 自己做这件事。

于 2012-09-30T17:55:25.137 回答
0

我不确定你的意思,但也许这对你有帮助......

[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeLeft animated:NO];

或者

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
于 2012-09-26T14:31:22.543 回答