Iphone xcode中mapkit中的重置按钮和书签按钮
我目前正在开发一个涉及mapkit的应用程序。我想在视图上添加一个重置按钮,当您打开程序时,该按钮会将视图重置为默认视图,或者更好的是,当您打开和关闭应用程序时,mapkit会自动重置 我用来设置初始区域的代码如下:Iphone xcode中mapkit中的重置按钮和书签按钮,iphone,objective-c,xcode,uibutton,mapkit,Iphone,Objective C,Xcode,Uibutton,Mapkit,我目前正在开发一个涉及mapkit的应用程序。我想在视图上添加一个重置按钮,当您打开程序时,该按钮会将视图重置为默认视图,或者更好的是,当您打开和关闭应用程序时,mapkit会自动重置 我用来设置初始区域的代码如下: MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; region.center.latitude = 54.049929; region.center.longitude = -4.54834; region
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];
任何帮助都将不胜感激。存储地图的位置 在.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];
那么,您是否在试图弄清楚如何实际将按钮添加到视图并将其链接到代码中的方法 方法中的代码本身与初始设置中使用的代码相同,如上面BuildSucceed所示
您只需在工具栏/导航栏上添加一个按钮(如果有),并将其链接到“resetMap()”方法。是否要将地图重新加载到初始设置?是的,这正是我要做的