[問題] 地圖定位
小弟在編寫地圖定位遇到一些瓶頸, 希望有大大可以幫忙解答
最近在研究map的使用
我很簡單的只放兩個Button和map view
一個Button用來定位, 一個用來將地圖移動到設定好的目標
主要是定位出了點問題, 用模擬器Run的時候只能成功定位一次
再次點擊的時候就都沒有反應了 不知道是哪裡有問題
以下是定位部分的程式碼
- (IBAction)showLocation:(id)sender {
if ([CLLocationManager authorizationStatus]==
kCLAuthorizationStatusDenied) {
UIAlertView* alertView =
[[UIAlertView alloc]
initWithTitle:@"使用者沒開放"
message:nil
delegate:nil
cancelButtonTitle:@"了解"
otherButtonTitles:nil, nil];
[alertView show];
[alertView release];
} else {
[m_mapView setShowsUserLocation:YES];
}}
-(void) mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation
*)userLocation
{
CLLocationCoordinate2D currentLocation = userLocation.coordinate;
MKCoordinateSpan defaultSpan = MKCoordinateSpanMake(0.005, 0.005);
[m_mapView setRegion:MKCoordinateRegionMake(currentLocation, defaultSpan)
animated:YES];
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 134.208.60.34
→
11/03 23:25, , 1F
11/03 23:25, 1F
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章