След выстроен в линию, но когда я прокручиваю, я получаю плохой результат.
Что касается версии моего приложения с 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;
}
Не знаю, поймешь ли ты что-нибудь. Мой код основан на тексте ссылки .
Спасибо за вашу помощь!! :)