2

I have created a custom annotation in swift and created an action handler for when somebody touches that type of annotation.

The problem is that I want the text to visible at all times without me having to click the annotation.

I want to do this because I want the user to see all the users on the map[see where each one is at every moment] and click on one of the annotations if he wants to open a chat view with that one.

Is there any way to do this?

Update 1:after Following Anna's advice I went ahead and added a label to the annotation subview. now I want to hide the label or do something with it when I click on the annotation

for things in view.subviews{
        if things.isKindOfClass(UILabel){
            var label = UILabel()
            label.text = " "
            things.textLabel = label
        }
    }

I get a label at the last attribution.How can I avoid that?

tudoricc
  • 709
  • 1
  • 12
  • 31
  • As per as I know, it is not possible. To see the map callout, the annotation needs to be manually touched. – ldindu Aug 19 '14 at 12:18
  • If you mean showing the callout popup, a callout can be shown programmatically by calling `selectAnnotation`. _However_, the MKMapView can only show one callout at a time. If you want multiple annotations to show certain info about themselves at the same time, you'll need to put that in the annotation view instead of the callout. –  Aug 19 '14 at 12:19
  • 1
    then is there a way to do something after clicking the title.I mean you first click the pin itself and after that if you touch the text something to happen – tudoricc Aug 19 '14 at 12:19
  • @Anna can you explain more on what you said?I don't quite understand – tudoricc Aug 19 '14 at 12:21
  • See http://stackoverflow.com/questions/24253631/how-to-display-title-for-multiple-annotations-directly-when-map-loaded. –  Aug 19 '14 at 12:28
  • @Anna even though you provided me with this information I am still having a hard time understanding how I can do this.The most tempting thing to do is modifying the callout but I don't find how to do this anywhere[after reading this post : http://stackoverflow.com/questions/2417952/multiple-annotation-callouts-displaying-in-mkmapview] can you give me some pointers? – tudoricc Aug 20 '14 at 09:55
  • Look at the other links provided in my comment [on this question](http://stackoverflow.com/questions/24253631/how-to-display-title-for-multiple-annotations-directly-when-map-loaded). Simplest thing is to NOT use the callout. Instead, in viewForAnnotation, add subviews (eg. a UILabel) to the annotation view which show the info you want to appear without user touching it. Another example: http://stackoverflow.com/questions/9822756/replace-icon-pin-by-text-label-in-annotation. –  Aug 20 '14 at 10:44
  • I want to thank you very much for the ideea and I have one more thing to ask you.When I click the annotation it goes to the method didSelectAnnotationView and I want to make the label hidden or at least delete the text?how may I go around doing that?I will add my try – tudoricc Aug 20 '14 at 12:47
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/59654/discussion-between-tudoricc-and-anna). – tudoricc Aug 20 '14 at 12:50

0 Answers0