2011-09-22 17 views
6

मैं एक ViewController में एक MKMapView है और जब वह/वह इन तरीकों के साथ नक्शा छू लेती है उपयोगकर्ताओं के जेस्चर का पता लगाने चाहते हैं:MKMapView पर उपयोगकर्ता छूता का पता लगाने आईओएस 5

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; 
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; 
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; 
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; 

एप्लिकेशन ठीक आईओएस के साथ काम करता

Pre-iOS 5.0 touch delivery method forwarding relied upon. Forwarding -touchesCancelled:withEvent: to <MKAnnotationContainerView: 0x634790; frame = (0 0; 262144 262144); autoresizesSubviews = NO; layer = <CALayer: 0x634710>> 

और इसके बाद के संस्करण 4 तरीकों में कोड तक पहुँच नहीं कर रहे हैं: 3, आईओएस 4 लेकिन जब मैं iOS 5 पर चल रहा है iPhone के साथ अनुप्रयोग डिबग, मैं इस संदेश को देखते हैं।

क्या आप इसे ठीक करने के बारे में जानते हैं?

धन्यवाद।

+1

आईओएस 5 पर अभी तक टिप्पणी नहीं कर सकता है लेकिन 3.2 से 4 के लिए, स्पर्श विधियों के बजाय यूआईजीएस्टर रिकॉग्नाइज़र का उपयोग करना आसान हो सकता है। – Anna

+0

http://stackoverflow.com/questions/1049889/how-to-intercept-touches-events-on-a-mkmapview-or-uiwebview-objects .. इस लिंक को चेक करें – Kalpesh

उत्तर

1

UIGestureRecognizer का कुछ रूप आपकी मदद कर सकता है। मानचित्र दृश्य पर उपयोग किए जा रहे टैप पहचानकर्ता का उदाहरण यहां दिया गया है; मुझे बताएं कि क्या यह वह नहीं है जिसे आप ढूंढ रहे हैं।

// in viewDidLoad... 

// Create map view 
MKMapView *mapView = [[MKMapView alloc] initWithFrame:(CGRect){ CGPointZero, 200.f, 200.f }]; 
[self.view addSubview:mapView]; 
_mapView = mapView; 

// Add tap recognizer, connect it to the view controller 
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mapViewTapped:)]; 
[mapView addGestureRecognizer:tapRecognizer]; 

// ... 

// Handle touch event 
- (void)mapViewTapped:(UITapGestureRecognizer *)recognizer 
{ 
    CGPoint pointTappedInMapView = [recognizer locationInView:_mapView]; 
    CLLocationCoordinate2D geoCoordinatesTapped = [_mapView convertPoint:pointTappedInMapView toCoordinateFromView:_mapView]; 

    switch (recognizer.state) { 
     case UIGestureRecognizerStateBegan: 
      /* equivalent to touchesBegan:withEvent: */ 
      break; 

     case UIGestureRecognizerStateChanged: 
      /* equivalent to touchesMoved:withEvent: */ 
      break; 

     case UIGestureRecognizerStateEnded: 
      /* equivalent to touchesEnded:withEvent: */ 
      break; 

     case UIGestureRecognizerStateCancelled: 
      /* equivalent to touchesCancelled:withEvent: */ 
      break; 

     default: 
      break; 
    } 
} 
संबंधित मुद्दे