2012-09-04 39 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視圖控制器。