我正在尝试使用CoreMotion框架构建一个增强现实应用程序。我试着脱离苹果的pARk示例代码项目,但它只在纵向模式下工作。我需要它在风景中发挥作用。当切换到景观模式时,重叠视图中的子视图以相反的方向以错误的速度移动(它们要么移动得太快,要么在屏幕上移动太慢)
我读过其他职位,它提供了两个解决方案:
我不认为第一个会起作用,因为我的增强现实应用程序要求它被引用到真正的北方。
我也不明白做第二题所需的数学。
对于如何解决这个复杂的问题,我表示欢迎。
发布于 2012-10-28 19:23:32
你现在在你的增强现实应用程序中有多远?我认为从苹果公司的PARk开始是很残酷的。你需要有一些先进的数学理解。但如果你这么做了,为什么不呢?
你可以看看这个存储库,这是一个增强现实项目,致力于肖像和景观模式。以下是如何处理轮调:
- (void)deviceOrientationDidChange:(NSNotification *)notification {
prevHeading = HEADING_NOT_SET;
[self currentDeviceOrientation];
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
// Later we may handle the Orientation of Faceup to show a Map. For now let's ignore it.
if (orientation != UIDeviceOrientationUnknown && orientation != UIDeviceOrientationFaceUp && orientation != UIDeviceOrientationFaceDown) {
CGAffineTransform transform = CGAffineTransformMakeRotation(degreesToRadian(0));
CGRect bounds = [[UIScreen mainScreen] bounds];
switch (orientation) {
case UIDeviceOrientationLandscapeLeft:
transform = CGAffineTransformMakeRotation(degreesToRadian(90));
bounds.size.width = [[UIScreen mainScreen] bounds].size.height;
bounds.size.height = [[UIScreen mainScreen] bounds].size.width;
break;
case UIDeviceOrientationLandscapeRight:
transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
bounds.size.width = [[UIScreen mainScreen] bounds].size.height;
bounds.size.height = [[UIScreen mainScreen] bounds].size.width;
break;
case UIDeviceOrientationPortraitUpsideDown:
transform = CGAffineTransformMakeRotation(degreesToRadian(180));
break;
default:
break;
}
[displayView setTransform:CGAffineTransformIdentity];
[displayView setTransform: transform];
[displayView setBounds:bounds];
degreeRange = [self displayView].bounds.size.width / ADJUST_BY;
}
}你必须旋转你所有的注解,然后你的覆盖视图后,设备旋转!
发布于 2013-01-04 15:35:03
如果您真的被困住了,并且愿意使用另一个工具包,请尝试iPhone-AR-工具包。它既适用于肖像,也适用于景观。
https://stackoverflow.com/questions/11906611
复制相似问题