Handle touch on MKMapView

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

  1. inverted macrumors newbie

    Jul 3, 2009

    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


    Nov 3, 2007
    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

    Jul 3, 2009
    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.

  4. inverted thread starter macrumors newbie

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

    @interface FriendAnnotationView : MKAnnotationView {

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

    [self.delegate showDetailsToFriend];
    [self.delegate hideDetailsToFriend];

    [super setSelected:selected animated:animated];

Share This Page