2016-10-01 2 views
0

Я выполняю одну функцию, когда пользователи нажимают кнопку, на карте указывается текущее местоположение пользователя по аннотации импульсной анимации.Текущее местоположение SKPulseAnimation не работает

SKCoordinateRegion region; 
region.center = CLLocationCoordinate2DMake(_currentLocation.coordinate.latitude, _currentLocation.coordinate.longitude); 
region.zoomLevel = 14; 
self.mapView.visibleRegion = region; 

SKAnnotation *CurrentLocationAnnotation = [SKAnnotation annotation]; 
CurrentLocationAnnotation.identifier = 1; 
//CurrentLocationAnnotation.annotationType = SKAnnotationTypeMarker; 
CurrentLocationAnnotation.location = CLLocationCoordinate2DMake(_currentLocation.coordinate.latitude, _currentLocation.coordinate.longitude); 
SKAnimationSettings *CurrentLocationanimationSettings = [SKAnimationSettings animationSettings]; 
CurrentLocationanimationSettings.animationType = SKPulseAnimation; 
CurrentLocationanimationSettings.animationEasingType = SKAnimationEaseLinear; 
CurrentLocationanimationSettings.duration = 7000; 
[self.mapView addAnnotation:CurrentLocationAnnotation withAnimationSettings:CurrentLocationanimationSettings]; 

Я попробовал его на симуляторе и на iphone, оба они вообще не работают. Как я могу это исправить? спасибо заранее

ответ

1
CLLocationCoordinate2D cordinate; 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    self.mapview.delegate=self; 
    self.locationManager.delegate = self 
    self.locationManager.distanceFilter = kCLDistanceFilterNone 
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest 
    [self.mapview setMapType:MKMapTypeSatellite]; 
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 54, 122, 21)]; 
    label.textAlignment = NSTextAlignmentCenter; 
    label.textColor = [UIColor whiteColor]; 
    label.backgroundColor = [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.3]; 
    label.text = @"title"; 

    //create our view for the image 
    UIImageView *coloredView1 = [[UIImageView alloc]initWithFrame:CGRectMake(7, 5.5, 122, 75)]; 
    coloredView1.image = [UIImage imageNamed:@"demo.png"]; 
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(7, 5.5, 122, 75)]; 
    view1.backgroundColor = [UIColor clearColor]; 
    [view1 addSubview:label]; 
    [view1 addSubview:coloredView1]; 

    //create our view for the background image 
    UIImageView *coloredView2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0.0, 136, 110)]; 
    coloredView2.image = [UIImage imageNamed:@"mapMarker"]; 
    UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(7, 5.5, 122, 75)]; 
    view1.backgroundColor = [UIColor clearColor]; 
    [view2 addSubview:coloredView2]; 
    [view2 addSubview:view1]; 

    //create our view for the background image 

    UIView *view3 = [[UIView alloc]initWithFrame:CGRectMake(0, 0.0, 136, 200)]; 
    view3.backgroundColor = [UIColor clearColor]; 
    [view3 addSubview:view2]; 

    SKAnnotationView *annotationView = [[SKAnnotationView alloc] initWithView:customAnnotationView reuseIdentifier:@"reusableIdentifier"]; 

    SKAnnotation *annotation = [SKAnnotation annotation]; 
    annotation.identifier = 123456; 
    annotation.location = region.center; 
    annotation.annotationView = annotationView; 

    [self.mapView addAnnotation:annotation withAnimationSettings:[SKAnimationSettings animationSettings]]; 

} 

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 
{ 
    if([annotation isKindOfClass:[MKUserLocation class]]) 
    { 
     return nil; 
    } 
    static NSString *identifier = @"myAnnotation"; 
    DraggableAnnotationView * annotationView = (DraggableAnnotationView *)[self.mapview dequeueReusableAnnotationViewWithIdentifier:identifier]; 
    if (!annotationView) 
    { 
     annotationView = [[DraggableAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; 
     annotationView.image = [UIImage imageNamed:@"ic_map_pin.png"]; 
    } 
    else 
    { 
     annotationView.annotation = annotation; 
    } 
    annotationView.delegate = self; 

    return annotationView; 
} 

, если этот код полезным для вас, то дать свой голос ... спасибо

Смежные вопросы