2 Replies
      Latest reply on Aug 16, 2019 4:37 PM by SteveAndrewartha
      SteveAndrewartha Level 1 Level 1 (0 points)

        I am successfully adding annotations to an MKMapView in all but one case:

         

            override func Show()

            {

                fDimmed = !IsVisible(point: coordinate)

                var ann = gMapView.annotations

                gMapView.addAnnotation(self)

                ann = gMapView.annotations

            }

         

        The "ann" variable is just debugging to inspect the annotations list before and after the addition and, sure enough, the annotation is added. However, the app returns to user control without ever calling the

         

        mapView(_ mapView: MKMapView, viewFor: MKAnnotation)

         

        function to actually place the annotation view.

         

        The class is declared as

         

        ViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate {}

         

        and as I said, with several other annotations, it works fine. Any ideas?

         

        Steve.

        • Re: MKAnnotation not appearing when added
          Claude31 Level 8 Level 8 (6,385 points)

          You should move your post to Maps and Location section. You'll get better feedback. Good luck.

          • Re: MKAnnotation not appearing when added
            SteveAndrewartha Level 1 Level 1 (0 points)

            I should add that the annotation itself is a Lodge, which is declared

             

            class Lodge: Mapsite, NSCoding

            {

                var fMember = false

                var fSaleItem:[Int] = [0,0,0,0]

                ....

            }

             

            class Mapsite: MapObject

            {

                var fIsLodge = false

                var fClues:    Int = 0

                var fXY:       [Int] = [0,0]

                var fLocation: [Double] = [0,0]

                var fDimmed = true

                ....

            }

             

            class MapObject: NSObject, MKAnnotation

            {

                var fIsCampfire = false

                var fIsExplorer = false

                var coordinate =  CLLocationCoordinate2D()

                var fView:        MKAnnotationView?

                ....

            }

             

            The variable required by the protocol (coordinate:CLLocationCoordinate2D) has a non-zero value but that's actually not relevant since, as I said, mapView is not even being called (I've set a breakpoint to verify that). The annotations that work are not Mapsites, they're in other subclasses of MapObject.