【问题标题】:iOS MKMapViewDelegate - Getting UserLocation the second timeiOS MKMapViewDelegate - 第二次获取 UserLocation
【发布时间】:2011-09-12 18:12:22
【问题描述】:

我创建了一个 MKMapView 并将一个 MKMapViewDelegate 与之关联。

MKMapViewDelegate 会正确收到 DidUpdateUserLocation 和其他生命周期事件发生的通知。

当我稍后在应用程序中创建另一个 MKMapView 时,MKMapViewDelegate 不会收到任何有关 MapLoaded 等的通知。只是构造函数被触发。

如何在第二次获取新地图实例以使用生命周期事件更新 MKMapViewDelegate?

【问题讨论】:

  • 是的,但是是新的。我发现如果我使用 RegionDidChange 事件,它会起作用。
  • 这听起来有点奇怪,不应该发生。你是如何创建两个地图视图的......你能发布一些示例代码吗?

标签: iphone ios xamarin.ios mkmapview mkmapviewdelegate


【解决方案1】:

在 iPhone 上使用 .NET (MonoTouch)

在 Map Delegate 中仅处理一次此事件,它会被触发很多。这样您就无需担心地图的缓存方式。

    public override void RegionChanged (MKMapView mapView, bool animated)
    {
        if (!hasSetupMapBoolean)
        {
            localCopymap = mapView;
            DoYourSetupMap ();
        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 1970-01-01
    • 2018-09-07
    • 1970-01-01
    相关资源
    最近更新 更多