Search code examples
iosxamarinxamarin.iosstoryboardxib

Its crashing while using the MKMapview variable which is added in xib ,Xamarin


I have added a MKMapview on storyboard of a xamarin ios project, Its crashing when I try to use the reference(object) of that map view

It is throwing Null Exception exception

following is my class.desinger class auto generated code

using Foundation;
using System;
using System.CodeDom.Compiler;
using UIKit;

namespace Running2Win.iOS
{
    [Register ("MapViewController")]
    partial class MapViewController
    {
        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        MapKit.MKMapView objMapView { get; set; }

        void ReleaseDesignerOutlets ()
        {
            if (objMapView != null) {
                objMapView.Dispose ();
                objMapView = null;
            }
        }
    }
}

and I am trying to access that map object in the viewdidload method of my class as follow

public override void ViewDidLoad ()
{
base.ViewDidLoad ();
objMapView.MapType = MKMapType.Standard; (Its crashing at this line by through Null exception for the objMapView variable)

}

I have deleted that class and re created but still this crash exists,,

Any help would be appreciable , Thanks in advance


Solution

  • I have resolved this issue By deleting and recreating that class