Xamarin Forms MapRenderer OnMapReady事件是否适用于iOS?

时间:2019-07-17 19:56:43

标签: xamarin.forms xamarin.ios google-maps-sdk-ios custom-renderer

我需要一个iOS渲染器的等效事件:

public class MyMapRenderer : Xamarin.Forms.Maps.Android.MapRenderer
{
    ...

    protected override void OnMapReady(GoogleMap map)
    {
        base.OnMapReady(map);

        // need to do things here
    }

    ...
}

谢谢

1 个答案:

答案 0 :(得分:0)

您可以使用MKMapViewDelegate_MapLoaded在iOS渲染器中处理您的操作:

 public class CustomMapRenderer : MapRenderer
    {

        protected override void OnElementChanged(ElementChangedEventArgs<View> e)
        {
            base.OnElementChanged(e);

            var nativeMap = Control as MKMapView;

            nativeMap.MapLoaded += NativeMap_MapLoaded;

        }

        private void NativeMap_MapLoaded(object sender, EventArgs e)
        {
            Console.WriteLine("NativeMap_MapLoaded");
        }
    }