線索是排隊,但當我滾動我得到一個壞結果。 關於我與MKAnnotatioView應用程序的版本,我可以告訴你的代碼,但我不能告訴你的日誌「引起不幸的是我不是現在iphone ...
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
self.startingPoint = newLocation;
CLLocation *lastLocation;
if([pointArray count] >= 2)
{
lastLocation = [pointArray objectAtIndex:1];
[pointArray removeAllObjects];
}
mapView.showsUserLocation = NO;
double lat,lon;
lat = newLocation.coordinate.latitude;
lon = newLocation.coordinate.longitude;
if(distanceIndex == 0)
{
[pointArray insertObject:newLocation atIndex:0];
}
else
{
if(distanceIndex == 1)
{
[pointArray insertObject:newLocation atIndex:1];
}
else
{
[pointArray insertObject:lastLocation atIndex:0];
[pointArray insertObject:newLocation atIndex:1];
}
}
if(distanceIndex == 0)
{
MarkPlace *mark = nil;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateStyle:NSDateFormatterNoStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateStr = [dateFormatter stringFromDate:[NSDate date]];
[dateFormatter release];
NSString *subtitle = [NSString stringWithFormat:@"Time Here: %@", dateStr];
mark = [[[MarkPlace alloc] initWithCoordinate:[[pointArray objectAtIndex:0] coordinate] currentTime:subtitle annotationType:MarkPlaceTypeEnd title:@"Pin Title"] autorelease];
[mapView addAnnotation:mark];
}
//create the route
MKCoordinateSpan span = mapView.region.span;
CLLocationCoordinate2D center = mapView.region.center;
IFRouteAnnotations *routeAnnotation = [[[IFRouteAnnotations alloc] initWithPoints:pointArray:0:span:center] autorelease];
[mapView addAnnotation:routeAnnotation];
[mapView setRegion:routeAnnotation.region animated:TRUE];
distanceIndex = distanceIndex + 1;
[routeAnnotation release];
}
-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
//re-enable and re-position the route display
for (NSObject *key in [routeViews allKeys]) {
IFRouteView *routeView = [routeViews objectForKey:key];
[routeView regionChanged];
}
}
-(MKAnnotationView *)mapView:(MKMapView *)_mapView viewForAnnotation:(id <MKAnnotation>)annotation{
MKAnnotationView *annotationView = nil;
NSLog(@"viewForAnnotation");
if(distanceIndex == 0)
{
MKPinAnnotationView *pin=[[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"] autorelease];
pin.pinColor = MKPinAnnotationColorGreen;
pin.animatesDrop = TRUE;
pin.userInteractionEnabled = YES;
annotationView = pin;
[annotationView setEnabled:YES];
[annotationView setCanShowCallout:YES];
}
if([annotation isKindOfClass:[IFRouteAnnotations class]])
{
IFRouteAnnotations *routeAnnotation = (IFRouteAnnotations *)annotation;
annotationView = [routeViews objectForKey:routeAnnotation.routeID];
if(annotationView == nil)
{
IFRouteView *routeView = [[[IFRouteView alloc] initWithFrame:CGRectMake(0,0, mapView.frame.size.width, mapView.frame.size.height)]autorelease];
routeView.annotation = routeAnnotation;
routeView.mapView = mapView;
[routeViews setObject:routeView forKey:routeAnnotation.routeID];
annotationView = routeView;
}
}
return annotationView;
}
我不知道你會明白的ything。我的代碼基於link text。 感謝您的幫助! :)
我不明白你的意思是什麼「基於路徑的顏色,做近鄰計算」。這不是更復雜嗎? 我仍然有面團,如果使用MKAnnotationView不是一個好主意。 MKAnnotationView是否消耗大量內存?我有我的應用程序的版本,我使用這個,但它創建一些註釋後,與低內存崩潰。 感謝您的回覆:) – ideafactory 2010-01-21 12:05:55
也許我誤解了。當你說運動不是完美的時候,我認爲你的意思是這條線沒有排成隊。即使它是準確的,你的意思是表現是不可接受的嗎? 來自Apple文檔: 「註釋對象不提供註釋的可視化表示,但通常會協調(連同地圖視圖的委託)創建適當的MKAnnotationView對象來處理顯示。」 所以如果你在一個小空間中使用很多座標(千)MKAnnotationView似乎並不正確。你能告訴我們代碼和崩潰日誌嗎? – 2010-01-21 14:07:44