2012-09-04 40 views
0

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

回答

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

0

我不知道你的意思到底是什么,但也许这可以帮助您...

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

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft]; 
2

我得到了同样的问题,解决它可笑!

我只需要拨打:

[reader willRotateToInterfaceOrientation: toInterfaceOrientation duration: duration]; 

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