Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8705259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:18:57+00:00 2026-06-13T03:18:57+00:00

I’m trying to follow a car on a map view. This code should animate

  • 0

I’m trying to follow a car on a map view.

This code should animate the car and the map with the same speed, so that the annotation view always appears in the center:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration: 1.0];
[UIView setAnimationBeginsFromCurrentState:YES];

[car setCoordinate:coord];
[mapView setCenterCoordinate:coord];

[UIView commitAnimations];

It worked fine in iOS 5. In iOS 6 the map is not animating anymore but the car does animate.

I tried [mapView setCenterCoordinate:co animated:YES], but then I cannot control the animation speed. It will always animate with the default duration (0.2s).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:18:59+00:00Added an answer on June 13, 2026 at 3:18 am

    It seems it is not possible to control the animation speed in iOS 6 when using these methods in MKMapView:

    - (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated;
    - (void)setCenterCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated;
    - (void)setVisibleMapRect:(MKMapRect)mapRect animated:(BOOL)animate;
    - (void)setVisibleMapRect:(MKMapRect)mapRect edgePadding:(UIEdgeInsets)insets animated:(BOOL)animate;
    

    However I found a private method that has a duration parameter. So I solved my issue by subclassing MKMapView and overriding the private method (which only exists in iOS6):

    MyMapView.h

    #import <MapKit/MapKit.h>
    
    @interface MyMapView : MKMapView
    
    @property(nonatomic) BOOL overridesAnimationDuration;
    @property(nonatomic) NSTimeInterval mapAnimationDuration;
    
    @end
    

    MyMapView.m

    @interface MKMapView (Private)
    - (void)_setZoomScale:(float)scale centerMapPoint:(CLLocationCoordinate2D)center duration:(double)d animationType:(int)animType;
    @end
    
    @implementation MyMapView
    - (void)_setZoomScale:(float)scale centerMapPoint:(CLLocationCoordinate2D)center duration:(double)d animationType:(int)animType
    {
        if (_overridesAnimationDuration) {
            d = _mapAnimationDuration;
        }
        [super _setZoomScale:scale centerMapPoint:center duration:d animationType:animType];
    }    
    @end
    

    I’ve added 2 properties that allow you to override the default animation time.
    To use it set overridesAnimationDuration to YES before a region change, set mapAnimationDuration to the desired duration and switch overridesAnimationDuration to NO in the delegate call mapView:regionWillChangeAnimated:.

    Note, this might not work in future iOS versions because it is private API. Apple can remove or change this method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.