开发者

A Reset button and a bookmark button in mapkit in xcode

I am currently working on an application involving mapkit. I would like to add a reset button on the view which re开发者_如何学JAVAsets the view to its default view when you open the program, or better still, the mapkit resets itself when you open and close the app.

The code i have used to set the initial region is as follows:

    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = 54.049929;
region.center.longitude = -4.54834;
region.span.longitudeDelta = 4.5;
region.span.latitudeDelta = 4.5;
[mapView setRegion:region animated:YES];

Any help would be greatly appreciated.


Store the Location of your map In .h file

CLLocationCoordinate2D location;

When setting initial Region

location.latitude = 54.049929;
location.longitude = -4.54834;

In your Reset Button

MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = location.latitude
region.center.longitude = location.longitude;
region.span.longitudeDelta = 4.5;
region.span.latitudeDelta = 4.5;
[mapView setRegion:region animated:YES];


So, are you trying to figure out how to actually add the button to the view and link it to a method in the code?

The code itself within the method would just be the same as you used for your initial setup, as indicated by BuildSucceded above ...

You should just add a button to the toolbar/navbar(if you have one), and link it to a "resetMap()" method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜