AVFoundation フレームワークを使用してカメラにアクセスします。標準のカメラアプリでは、向きを変えるとボタン上のアイコンの回転だけが変わります。しかし、次のようなことをしようとすると、向きの変更アニメーションに関連する問題が発生します。プレビュー ビューが回転し、その後ろの領域が黒くなり、回転すると画像がぎくしゃくします。
今、私はこのコードを持っています:
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:duration]
forKey:kCATransactionAnimationDuration];
if (toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft){
captureManager.previewLayer.transform=CATransform3DMakeRotation(M_PI/2, 0, 0, 1.0);
captureManager.previewLayer.frame = CGRectMake(0, 0, 480, 320);
} else if (toInterfaceOrientation==UIInterfaceOrientationPortrait){
captureManager.previewLayer.transform=CATransform3DMakeRotation(0, 0, 0, 1.0);
captureManager.previewLayer.frame = CGRectMake(0, 0, 320, 480);
} else if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight){
captureManager.previewLayer.transform=CATransform3DMakeRotation(M_PI+M_PI/2, 0, 0, 1.0);
captureManager.previewLayer.frame = CGRectMake(0, 0, 480, 320);
}
[CATransaction commit];
}
私の考えでは、変換アニメーションを使用して回転アニメーションを処理していますが、グライズで問題が発生します。
カメラ プレビュー ビューを作成し、向きの変更に関する問題を解決するにはどうすればよいですか? カメラを操作するには、他の機器を使用する必要がありますか? AVFoundation フレームワークではありませんか?
方向をロックし、加速度計を使用してボタン アイコンを処理できることを知っています。しかし、いくつかのサブビューコントローラーで問題が発生します。
ひどい英語でごめんなさい。