2012-11-15 27 views
3

我曾在iPhone和iPad的Zbar上工作過,沒有任何問題,但沒有使用iPad中的橫向模式。當我在ipad與橫向模式酥料餅呈現ZBarReaderViewController,視圖是90度移如下面的圖像中,用於在iPad中進行橫向拍攝的ZBar

Zbar in landscape

其中所述袋在桌子上,並且圖像被在與iPad捕獲風景模式。我希望袋子圖像不會偏移。

我已經嘗試設置supportedOrientationsMask作爲

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

但其在正確的方向沒有顯示,但它是一個90度的轉向。有人可以幫我解決這個問題嗎?任何及時的幫助都更值得讚賞。謝謝。

回答

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

應被標記爲正確答案。 有同樣的問題,它確實修復了它。 – Maverick1st

+0

此行爲的實際原因是默認情況下,ZBar SDK用於捕獲圖像的UIImagePickerController處於縱向方向。 –

+0

+1,[self.readerView willRotateToInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation] duration:0]不能按預期工作 –

1

這種解決方案的事情是修復只是問題的視覺部分。用戶看到了正確的方向,但ZBarReader仍然「看到」相同的圖像,因爲您正在轉換預覽圖像。什麼工作是這樣的:

[self.readerView willRotateToInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation] duration:0]; 
在包含ZBarReaderView你的ViewController的 viewDidLoad方法

相關問題