Controlling Animation Duration in Google Maps for iOS

前端 未结 4 1569
广开言路
广开言路 2021-02-02 10:16

The documentation for Google Maps for iOS states that:

Call one of several methods that allow you to animate the camera moving to a new location. You can

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-02 10:35

    what a pitty that using the same methods you provided there is no way to know if the animation has ended.

    Yes I know, there is a CATransaction completion block using this method but it does simply not work! :(

    [CATransaction begin];
    [CATransaction setValue:[NSNumber numberWithFloat: 1.0f] forKey:kCATransactionAnimationDuration];
    
    [CATransaction setCompletionBlock:^{
    // ... whatever you want to do when the animation is complete
    }];
    
    [self.googleMapsView animateToCameraPosition:[GMSCameraPosition 
                        cameraWithLatitude:LATITUDE
                                 longitude:LONGITUDE
                                      zoom:ZOOM]];
    
    [CATransaction commit];
    

    And I can't use MapView:didIdle hack to know that the animation has ended because it will not be called if there is no camera position change.

    Anyone knows how to detect animateon has ended event?

    FOUND A THREAD ABOUT THIS (solved): CATransaction completion being called immediately

提交回复
热议问题