Handle touch on MKMapView

Discussion in 'iOS Programming' started by inverted, Jul 3, 2009.

  1. inverted macrumors newbie

    Joined:
    Jul 3, 2009
    #1
    hey

    i am using an MKMapView. i initialize it directly from the code.
    when i touch an annotation on the map i 'move' (transfer) another view above the MKMapView to show to the user some details about the annotation.

    now my question, how do i handle a touch somewhere else on the map ? cause in this case i want to close the details view again.

    thank you for your help !
     
  2. Jeremy1026 macrumors 68020

    Jeremy1026

    Joined:
    Nov 3, 2007
    #2
    That will tell you when an annotation is selected. Too bad I couldn't even get the sample code to work :confused:. If you get it to work please post your code.
     
  3. inverted thread starter macrumors newbie

    Joined:
    Jul 3, 2009
    #3
    hi, i was able to handle the "select"-event. for that i made my own subclass from "MKAnnotationView" and overwrote the - (void)setSelected:(BOOL)selected animated:(BOOL)animated; method.
    but the way you showed me is much better. you don't mess up with the responsibility.

    but i am looking for a solution to do the opposite :) i have to handle a touch inside the map, and not on an annotation.
    i need that to hide my detailsView.

    thanks
     
  4. inverted thread starter macrumors newbie

    Joined:
    Jul 3, 2009
    #4
    haha sometimes i could kick myself !
    i found the answer :

    @interface FriendAnnotationView : MKAnnotationView {
    ....

    - (void)setSelected: (BOOL)selected animated: (BOOL)animated{

    if(selected){
    [self.delegate showDetailsToFriend];
    }
    else{
    [self.delegate hideDetailsToFriend];
    }

    [super setSelected:selected animated:animated];
    }
     

Share This Page