Show callout for disclosureindicator for MKAnnotationView in Swift
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
add a comment |
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
add a comment |
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
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
ios swift mkannotationview calloutview
asked Nov 14 '18 at 19:40
user1904273user1904273
1,64882965
1,64882965
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You need this delegate method
func mapView(_ mapView: MKMapView,
annotationView view: MKAnnotationView,
calloutAccessoryControlTapped control: UIControl)
with
self.mapView.delegate = self
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
add a comment |
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
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
You need this delegate method
func mapView(_ mapView: MKMapView,
annotationView view: MKAnnotationView,
calloutAccessoryControlTapped control: UIControl)
with
self.mapView.delegate = self
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
add a comment |
You need this delegate method
func mapView(_ mapView: MKMapView,
annotationView view: MKAnnotationView,
calloutAccessoryControlTapped control: UIControl)
with
self.mapView.delegate = self
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
add a comment |
You need this delegate method
func mapView(_ mapView: MKMapView,
annotationView view: MKAnnotationView,
calloutAccessoryControlTapped control: UIControl)
with
self.mapView.delegate = self
You need this delegate method
func mapView(_ mapView: MKMapView,
annotationView view: MKAnnotationView,
calloutAccessoryControlTapped control: UIControl)
with
self.mapView.delegate = self
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
add a comment |
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
add a comment |
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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