Show callout for disclosureindicator for MKAnnotationView in Swift










0















I am able to show a disclosure icon in on my map annotation using the following code.



 annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)


When you press the disclosure icon, it blinks but nothing else happens. I tried putting a button handler on it but it is not a button so the compiler said no. Do I have to create a whole gesturerecognizer to get it to do anything or how would I get a press on the the indicator to show information about the location?










share|improve this question


























    0















    I am able to show a disclosure icon in on my map annotation using the following code.



     annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
    annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)


    When you press the disclosure icon, it blinks but nothing else happens. I tried putting a button handler on it but it is not a button so the compiler said no. Do I have to create a whole gesturerecognizer to get it to do anything or how would I get a press on the the indicator to show information about the location?










    share|improve this question
























      0












      0








      0








      I am able to show a disclosure icon in on my map annotation using the following code.



       annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
      annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)


      When you press the disclosure icon, it blinks but nothing else happens. I tried putting a button handler on it but it is not a button so the compiler said no. Do I have to create a whole gesturerecognizer to get it to do anything or how would I get a press on the the indicator to show information about the location?










      share|improve this question














      I am able to show a disclosure icon in on my map annotation using the following code.



       annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
      annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)


      When you press the disclosure icon, it blinks but nothing else happens. I tried putting a button handler on it but it is not a button so the compiler said no. Do I have to create a whole gesturerecognizer to get it to do anything or how would I get a press on the the indicator to show information about the location?







      ios swift mkannotationview calloutview






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 19:40









      user1904273user1904273

      1,64882965




      1,64882965






















          2 Answers
          2






          active

          oldest

          votes


















          1














          You need this delegate method



          func mapView(_ mapView: MKMapView, 
          annotationView view: MKAnnotationView,
          calloutAccessoryControlTapped control: UIControl)


          with



          self.mapView.delegate = self





          share|improve this answer

























          • One question if you come back to this. Is there a recommended way to create a view when the disclosure control is tapped to show additional information such as a small callout view to the calloutview or an expanded calloutview? All I want to do is show a address and phone number. Are we supposed to make a new view ourselves and display it or is there something built in?

            – user1904273
            Nov 15 '18 at 19:57



















          -1














          Try this



           let btn = UIButton(type: .detailDisclosure)
          btn.addTarget(self, action: #selector(btnDisclosureAction(_:)), for: .touchUpInside)
          annotationView.rightCalloutAccessoryView = btn

          @objc func btnDisclosureAction(_ sender: UIButton)
          // you action






          share|improve this answer

























          • Hey, can anyone let me know what's wrong with this code, just want to understand how people downvote answers

            – Satish
            Nov 14 '18 at 20:57










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307647%2fshow-callout-for-disclosureindicator-for-mkannotationview-in-swift%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You need this delegate method



          func mapView(_ mapView: MKMapView, 
          annotationView view: MKAnnotationView,
          calloutAccessoryControlTapped control: UIControl)


          with



          self.mapView.delegate = self





          share|improve this answer

























          • One question if you come back to this. Is there a recommended way to create a view when the disclosure control is tapped to show additional information such as a small callout view to the calloutview or an expanded calloutview? All I want to do is show a address and phone number. Are we supposed to make a new view ourselves and display it or is there something built in?

            – user1904273
            Nov 15 '18 at 19:57
















          1














          You need this delegate method



          func mapView(_ mapView: MKMapView, 
          annotationView view: MKAnnotationView,
          calloutAccessoryControlTapped control: UIControl)


          with



          self.mapView.delegate = self





          share|improve this answer

























          • One question if you come back to this. Is there a recommended way to create a view when the disclosure control is tapped to show additional information such as a small callout view to the calloutview or an expanded calloutview? All I want to do is show a address and phone number. Are we supposed to make a new view ourselves and display it or is there something built in?

            – user1904273
            Nov 15 '18 at 19:57














          1












          1








          1







          You need this delegate method



          func mapView(_ mapView: MKMapView, 
          annotationView view: MKAnnotationView,
          calloutAccessoryControlTapped control: UIControl)


          with



          self.mapView.delegate = self





          share|improve this answer















          You need this delegate method



          func mapView(_ mapView: MKMapView, 
          annotationView view: MKAnnotationView,
          calloutAccessoryControlTapped control: UIControl)


          with



          self.mapView.delegate = self






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 24 '18 at 1:07

























          answered Nov 14 '18 at 20:07









          Sh_KhanSh_Khan

          43.7k51329




          43.7k51329












          • One question if you come back to this. Is there a recommended way to create a view when the disclosure control is tapped to show additional information such as a small callout view to the calloutview or an expanded calloutview? All I want to do is show a address and phone number. Are we supposed to make a new view ourselves and display it or is there something built in?

            – user1904273
            Nov 15 '18 at 19:57


















          • One question if you come back to this. Is there a recommended way to create a view when the disclosure control is tapped to show additional information such as a small callout view to the calloutview or an expanded calloutview? All I want to do is show a address and phone number. Are we supposed to make a new view ourselves and display it or is there something built in?

            – user1904273
            Nov 15 '18 at 19:57

















          One question if you come back to this. Is there a recommended way to create a view when the disclosure control is tapped to show additional information such as a small callout view to the calloutview or an expanded calloutview? All I want to do is show a address and phone number. Are we supposed to make a new view ourselves and display it or is there something built in?

          – user1904273
          Nov 15 '18 at 19:57






          One question if you come back to this. Is there a recommended way to create a view when the disclosure control is tapped to show additional information such as a small callout view to the calloutview or an expanded calloutview? All I want to do is show a address and phone number. Are we supposed to make a new view ourselves and display it or is there something built in?

          – user1904273
          Nov 15 '18 at 19:57














          -1














          Try this



           let btn = UIButton(type: .detailDisclosure)
          btn.addTarget(self, action: #selector(btnDisclosureAction(_:)), for: .touchUpInside)
          annotationView.rightCalloutAccessoryView = btn

          @objc func btnDisclosureAction(_ sender: UIButton)
          // you action






          share|improve this answer

























          • Hey, can anyone let me know what's wrong with this code, just want to understand how people downvote answers

            – Satish
            Nov 14 '18 at 20:57















          -1














          Try this



           let btn = UIButton(type: .detailDisclosure)
          btn.addTarget(self, action: #selector(btnDisclosureAction(_:)), for: .touchUpInside)
          annotationView.rightCalloutAccessoryView = btn

          @objc func btnDisclosureAction(_ sender: UIButton)
          // you action






          share|improve this answer

























          • Hey, can anyone let me know what's wrong with this code, just want to understand how people downvote answers

            – Satish
            Nov 14 '18 at 20:57













          -1












          -1








          -1







          Try this



           let btn = UIButton(type: .detailDisclosure)
          btn.addTarget(self, action: #selector(btnDisclosureAction(_:)), for: .touchUpInside)
          annotationView.rightCalloutAccessoryView = btn

          @objc func btnDisclosureAction(_ sender: UIButton)
          // you action






          share|improve this answer















          Try this



           let btn = UIButton(type: .detailDisclosure)
          btn.addTarget(self, action: #selector(btnDisclosureAction(_:)), for: .touchUpInside)
          annotationView.rightCalloutAccessoryView = btn

          @objc func btnDisclosureAction(_ sender: UIButton)
          // you action







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 14 '18 at 20:55

























          answered Nov 14 '18 at 19:55









          SatishSatish

          1,036615




          1,036615












          • Hey, can anyone let me know what's wrong with this code, just want to understand how people downvote answers

            – Satish
            Nov 14 '18 at 20:57

















          • Hey, can anyone let me know what's wrong with this code, just want to understand how people downvote answers

            – Satish
            Nov 14 '18 at 20:57
















          Hey, can anyone let me know what's wrong with this code, just want to understand how people downvote answers

          – Satish
          Nov 14 '18 at 20:57





          Hey, can anyone let me know what's wrong with this code, just want to understand how people downvote answers

          – Satish
          Nov 14 '18 at 20:57

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307647%2fshow-callout-for-disclosureindicator-for-mkannotationview-in-swift%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3