xcode 中的 Mapkit 中的重置按钮和书签按钮

发布于 2024-10-04 13:31:34 字数 415 浏览 3 评论 0原文

我目前正在开发一个涉及mapkit 的应用程序。我想在视图上添加一个重置按钮,当您打开程序时,该按钮会将视图重置为其默认视图,或者更好的是,当您打开和关闭应用程序时,mapkit 会自行重置。

我用来设置初始区域的代码如下:

    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];

任何帮助将不胜感激。

I am currently working on an application involving mapkit. I would like to add a reset button on the view which resets 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

腻橙味 2024-10-11 13:31:34

存储地图的位置
在 .h 文件中

CLLocationCoordinate2D location;

设置初始区域时

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

在重置按钮中

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];

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];
蹲墙角沉默 2024-10-11 13:31:34

那么,您是否想弄清楚如何实际将按钮添加到视图并将其链接到代码中的方法?

该方法中的代码本身与您用于初始设置的代码相同,如上面的 BuildSucceded 所示...

您应该只向工具栏/导航栏添加一个按钮(如果有的话),并将其链接到“resetMap()”方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文