私の iPhone アプリケーションでは、UnfieyeMobileViewController で metaio sdk を使用しています。EAGLView コンポーネントでカメラ ビューを表示するようにビューをカスタマイズしましたが、正常に動作します。デバイスを回転させても、カメラの向きが変わらないという問題。また、キャプチャされた画像が上下逆さまに表示されます。これが私のコードです。確認してください:
ViewDidAppear で:
UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;
[self willAnimateRotationToInterfaceOrientation:interfaceOrientation duration:0];
[super viewDidAppear:animated];
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
// adjust the rotation based on the interface orientation
switch (interfaceOrientation) {
case UIInterfaceOrientationPortrait:
self.glView.transform = CGAffineTransformMakeRotation(0);
break;
case UIInterfaceOrientationPortraitUpsideDown:
self.glView.transform = CGAffineTransformMakeRotation(M_PI);
break;
case UIInterfaceOrientationLandscapeLeft:
self.glView.transform = CGAffineTransformMakeRotation(M_PI_2);
break;
case UIInterfaceOrientationLandscapeRight:
self.glView.transform = CGAffineTransformMakeRotation(-M_PI_2);
break;
}
// make sure the screen bounds are set correctly
CGRect mainBounds = [UIScreen mainScreen].bounds;
if( UIInterfaceOrientationIsLandscape(interfaceOrientation) )
{
int width = mainBounds.size.width;
int height = mainBounds.size.height;
mainBounds.size.width = height;
mainBounds.size.height = width;
}
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
// for iPhone the aspect ratio does not fit, so let's correct it
if( UIInterfaceOrientationIsLandscape(interfaceOrientation) )
{
mainBounds.size.height = 360; // because our renderer is a bit larger
mainBounds.origin.y = -20;
}
else
{
mainBounds.size.width = 360; // because our renderer is a bit larger
mainBounds.origin.x = -20;
}
}
self.glView.frame = mainBounds;
}