現在、QR コードの読み取りに ZBarSDK を使用する iPad アプリケーションを開発しています。
私はZBarReaderView  (NOT ) を使用しているので、を使用して描画されUIViewControllerた正面カメラを表示しています (以下のコードを参照)。UIViewCGRect
私の問題は、カメラがビュー内の側面に来ることです。iPad アプリは、ランドスケープ モードで動作するようにのみ開発されます。
がUIView表示されると、画像が横になっていて、修正方法がわかりません。うまく角度を変えて使っCGAffineTransformてみたのですが、iPadが逆向きになった場合はどうなりますか?
この同様の問題に関する他の投稿を見ましたが、解決策はありませんでした。私はIOS6を使用していることに注意してZBarReaderViewくださいsupportedOrientationsMask.
横向きが左か右かに関係なく、ユーザーがカメラ ビューを直立した位置で見られるようにします。ただ今は、どちらを向いても映像が横向きです(自分が90度横に見えるように)。UIView画面を回転させても全く変わりません。私は少し迷っています。
コード:
- (void) viewDidAppear: (BOOL) animated {
    ZBarReaderView * readerView = [ZBarReaderView new];
    ZBarImageScanner * scanner = [ZBarImageScanner new];
    [scanner setSymbology: ZBAR_I25
                   config: ZBAR_CFG_ENABLE
                       to: 0];
    [readerView initWithImageScanner:scanner];
    readerView.readerDelegate = self;
    readerView.tracksSymbols = YES;
    readerView.frame = CGRectMake(20,220,230,230);
    readerView.torchMode = 0;
    readerView.device = [self frontFacingCameraIfAvailable];
    [readerView start];
    [self.view addSubview: readerView];
}
-(void)relocateReaderPopover:(UIInterfaceOrientation)toInterfaceOrientation {
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        readerView.previewTransform = CGAffineTransformMakeRotation(M_PI_2);
    } else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        readerView.previewTransform = CGAffineTransformMakeRotation(-M_PI_2);
    } else if (toInterfaceOrientation== UIInterfaceOrientationPortraitUpsideDown) {
        readerView.previewTransform = CGAffineTransformMakeRotation(M_PI);
    } else {
        readerView.previewTransform = CGAffineTransformIdentity;
    }
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        return YES;
    } else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        return YES;
    } else {
        return NO;
    }
}
- (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) orient
                                 duration: (NSTimeInterval) duration
{
    if (orient == UIInterfaceOrientationLandscapeLeft) {
        [readerView willRotateToInterfaceOrientation: orient
                                            duration: duration];
    }
    if (orient == UIInterfaceOrientationLandscapeRight) {
        [readerView willRotateToInterfaceOrientation: orient
                                            duration: duration];
    }
}
- (BOOL)shouldAutorotate {
    UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (orientation == UIInterfaceOrientationLandscapeLeft) {
        return YES;
    } else if (orientation == UIInterfaceOrientationLandscapeRight) {
        return YES;
    } else {
        return NO;
    }
}
-(NSUInteger) supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}