2016-10-01 19 views
0

私は1つの機能を実行しています。ユーザーがボタンを押したときに、マップはパルスアニメーションによるユーザーの現在の位置を示します。現在の位置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; 
} 

あなたのために役立つ、このコードは、その後、あなたの投票を与える場合は事前のおかげで...あなたに

に感謝します
関連する問題