Reputation: 37
I'm in the middle of creating an app using Mapkit in iOS and what I'd really like to do would be to show a specific location on the map........pause.......then zoom to users location.
I have the following in my code but have no idea how to apply the pause or if this is possible?
CLLocationCoordinate2D zoomLocation; //Sheffield Centre ,
zoomLocation.latitude = 53.381129;
zoomLocation.longitude= -1.470085;
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 1.0*METERS_PER_MILE, 1.0*METERS_PER_MILE);
[_mapView setRegion:viewRegion animated:YES];
//_mapView.userTrackingMode=YES;
Anyone's help would be greatly appreciated!
Upvotes: 1
Views: 83
Reputation: 438142
If you want to perform some action after a certain amount of time, you can use the GCD dispatch_after
:
double delayInSeconds = 0.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[_mapView setRegion:viewRegion animated:YES];
});
Upvotes: 1