UIImage
からを受け取り、AVCaptureSession
に設定していますUIImageView
。ポートレート モードでは画像が正しい向きに設定されますが、ランドスケープ モードを使用すると、画像が時計回りに 90 度回転して設定されます。
少し調べてみたところUIImageOrientation
、この方法を使用して問題を解決 できることがわかりました。
[UIImage imageWithCGImage:cgimageref scale:1 orientation:orientation]
しかし、私はその方法を理解していません。すべての画像を見ると、ポートレート モードとランドスケープ モードの両方UIImageOrientation
で、値は常に 3 ( ) です。NSLog(@"%d",UIImageOrientation)
これがどのように私を助けることができるかについて私は困惑しています。何か不足していますか?
方向コードは次のとおりです。
-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
self.prevLayer.frame = self.view.bounds;
self.prevLayer.orientation = [[UIDevice currentDevice] orientation];
}
shouldAutorotateToInterfaceOrientation は YES を返します。