アプリケーションへのマップキットと注釈の追加に関するこのチュートリアル ( http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/ ) に従っています。ただし、ユーザーの場所に真剣に取り組んでいます。私はxcodeが初めてなので、次に何をすべきかよくわかりません。私はトニーのオプションを試しました:
step one: add the CoreLocation framework to the project.
Step two: add this function to the iCodeMapViewController.m:
- (void)setCurrentLocation:(CLLocation *)location {
MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}};
region.center = location.coordinate;
region.span.longitudeDelta = 0.15f;
region.span.latitudeDelta = 0.15f;
[self.mapView setRegion:region animated:YES];
}
step three: add this code to the ViewForAnnotation Method:
if (annotation != mapView.userLocation) {
//the rest of the ViewForAnnotation code goes here
}else{
CLLocation *location = [[CLLocation alloc]
initWithLatitude:annotation.coordinate.latitude
longitude:annotation.coordinate.longitude];
[self setCurrentLocation:location];
}
しかし、私がビルドに行くとき、それは好きではありません。
私もこのオプションを試しました:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation
{
if ([annotation isKindOfClass:MKUserLocation.class]) return nil;
//rest of code
}
青い点が表示され、カスタム注釈が表示されますが、テーブルをスクロールしようとするとアプリがクラッシュします。デバッガーは助けを提供しませんが、このステートメントで停止します。
誰か助けてくれませんか?コード例も?この投稿への回答は、マップキットにも苦労している多くの人々に役立つと思います。
乾杯