代码之家  ›  专栏  ›  技术社区  ›  Barney Chambers

Xamarin C#-IMKAnnotation不包含“x”的定义

  •  2
  • Barney Chambers  · 技术社区  · 8 年前

    我的 MKAnnotation annotation IsEmergency ,但当我运行此代码时:

     if (annotation.IsEmergency == "0")
            {
                //doStuff();
            }
    

    annotation 对象不包含的定义 I紧急情况

    enter image description here

    在我提供的屏幕截图中,你可以看到我的对象包含这个变量。

    以下是完整错误:

    Severity    Code    Description Project File    Line    Suppression State
    Error   CS1061  'IMKAnnotation' does not contain a definition for 'IsEmergency' and no extension method 'IsEmergency' accepting a first argument of type 'IMKAnnotation' could be found (are you missing a using directive or an assembly reference?)       270 Active
    
    1 回复  |  直到 8 年前
        1
  •  2
  •   SushiHangover    8 年前

    该映射委托方法是通过一个 IMKAnnotation

    var myAnnotation = annotation as `YourMKAnnotationSubClass`;
    if (myAnnotation?.IsEmergency == "0")
    {
        //doStuff();
    }