2010-11-26 45 views
0

我目前正在研究一個涉及mapkit的應用程序。我想在視圖上添加一個重置按鈕,在打開程序時將視圖重置爲其默認視圖,或者更好的是,當您打開並關閉應用程序時,mapkit會自行重置。xcode中的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]; 

任何幫助,將不勝感激。

+0

是否要將地圖重新​​加載到初始設置? – KingofBliss 2010-11-26 16:54:31

回答

0

商店地圖 的位置在.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]; 
0

所以,你想弄清楚如何實際將按鈕添加到視圖並將其鏈接到代碼中的方法?

方法中的代碼本身也只是作爲您用於初始設置,通過上述BuildSucceded指示的一樣...

您應該只是一個按鈕添加到工具欄/導航欄(如果你有一個),並將其鏈接到「resetMap()」方法。