【问题标题】:iPhone: offset with compass heading values between landscape right and landscape leftiPhone:在横向右侧和横向左侧之间偏移罗盘航向值
【发布时间】:2012-11-13 09:36:43
【问题描述】:

要明确我的问题是没有读取横向或左侧的标题值。它工作正常我正在使用位置管理器并减去 90° 以读取横向右侧的航向值和 270° 横向左侧的航向值,默认情况下,设备始终被视为纵向模式,这就是我们必须进行此调整的原因。

我最近开发了一个基于位置的增强现实应用程序,我遇到的情况是,左右横向之间的航向值总是存在偏移。我在“现场”测试过,偏移大约是 12°。

我希望这个应用程序尽可能准确,我的意思是因为我们在这里依赖传感器数据并且这是第一个版本,所以小于 10° 是可以接受的(在最坏的情况下甚至是 15°)。但是,如果我们在现有误差上加上 12° 的偏移量,那就很烦人了。

有人对此有解释吗?即使我现在无法修复它,我也想要一个。所以现在我正在尝试通过向左横向添加 12° 来“修复”这个问题,或者我应该在右侧横向减去 12°,我不知道!

在这个问题上有什么经验吗?

【问题讨论】:

    标签: ios augmented-reality cllocationmanager compass-geolocation


    【解决方案1】:

    我的经验是指南针不是很好,尤其是在横向视图中。我不会在一个视图中减去 12°,因为差异可能在另一台设备上有所不同。我建议您在继续之前先在其他一两部 iPhone 上进行测试。

    另外,你是在设置 LocationManager 的视图吗?

    CLLocationManager *compassManager;
    compassManager.headingOrientation =CLDeviceOrientationLandscapeLeft;
    

    【讨论】:

    • 感谢您的提示,不胜感激!事实上我没有设置这个属性,所以现在使用它可以防止我通过减去 90° 或 270° 来实现这一点,现在代码更清晰了。好吧,我不得不承认我不能对指南针的准确性做更多的事情,避免在其他设备上增加 12° 会更明智。在这个应用程序发布后,我计划开发一个使用 Core Motion 作为标题的 2.0 版本,并利用 Apple 的示例项目 pARk。它不能更糟:)
    • +1 为 compassManager.headingOrientation =CLDeviceOrientationLandscapeLeft; - 帮助我
    • iPhone在纵向和横向中间时的调整是什么?
    【解决方案2】:

    我也遇到了这个问题,LandscapeLeft、landscapeRight 和 Portrait 之间存在差异。感谢 Sten 的回复和下面的 Swift 代码解决了这个问题。

    override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
        var text=""
        switch UIDevice.currentDevice().orientation{
        case .Portrait:
            text="Portrait"
            locationManager.headingOrientation = CLDeviceOrientation.Portrait
        case .PortraitUpsideDown:
            text="PortraitUpsideDown"
            locationManager.headingOrientation = CLDeviceOrientation.Portrait
        case .LandscapeLeft:
            text="LandscapeLeft"
            locationManager.headingOrientation = CLDeviceOrientation.LandscapeLeft
        case .LandscapeRight:
            text="LandscapeRight"
            locationManager.headingOrientation = CLDeviceOrientation.LandscapeRight
        default:
            text="Another"
        }
        NSLog("You have moved: \(text)")
    
    }
    

    【讨论】:

    • 但只有在info.plist 选择了所有方向时该方法才会运行?
    猜你喜欢
    • 2014-11-20
    • 1970-01-01
    • 1970-01-01
    • 2011-07-02
    • 1970-01-01
    • 2013-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多