2014-10-22 95 views
0

我想知道如果有人能夠幫助我。我是xcode的新手,我試圖構建一個基本的應用程序。我按照這個教程Xcode6 IOS8 mapkit pins不顯示

http://rshankar.com/how-to-add-annotation-to-mapview-in-ios/

我抄的源代碼直接,我沒有得到任何錯誤或警告,但在運行應用程序的引腳位置不顯示的時候。我不知道他們是否在那裏(只是看不見),或者他們根本沒有出現。我似乎無法找到問題。

任何人都可以提出什麼問題可以嗎?

在此先感謝。

回答

0

實際上設法解決這個問題,原來座標是錯誤的方式! Noob錯誤!如果有人可以在教程中更改代碼的位置,我想更改引腳上的標註。 感謝

0

要更改引腳的標註:

  • 讓有你的地圖視圖實現<MKMapViewDelegate>協議
  • 設置你的地圖視圖的delegate到類的類(如mapView.delegate = self;
  • 在該類實施MKMapViewDelegate(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation方法

小號omething這樣的:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    // If it's the user location, just return nil 
    if ([annotation isKindOfClass:[MKUserLocation class]]) 
     return nil; 

    // Handle custom annotations 
    if ([annotation isKindOfClass:[NAME_OF_CLASS_IMPLEMENTING_MKANNOTATION_PROTOCOL class]]) 
    { 
     // Try to dequeue an existing annotation view first 
     MKAnnotationView *annotationView = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"AnnotationViewIdentifier"]; 

     if (!annotationView) 
     { 
      // If an existing pin view was not available, create one 
      annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"AnnotationViewIdentifier"]; 
      annotationView.canShowCallout = YES; 

      // set callout 
      UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
      annotationView.rightCalloutAccessoryView = rightButton; 
     } 
     else 
     { 
      annotationView.annotation = annotation; 
     } 

     return annotationView; 
    } 

    return nil; 
} 

在地圖管腳(這應該從實現MKAnnotation協議的類進行),你應該能夠設置titlesubtitle性能。