2011-08-29 85 views
0

我使用follwing代碼來顯示給定緯度經度值的形象,但它給錯誤的MKMapView沒有顯示地圖

NSString*lat=latitude; 
NSString*longi=longitude; 


mapView = [[MKMapView alloc] initWithFrame:self.view.bounds]; 
mapView.mapType = MKMapTypeHybrid;mapView.mapType=MKMapTypeHybrid; 

double _lat = [lat doubleValue]; 
double _lng = [longi doubleValue]; 
CLLocationCoordinate2D coord = (CLLocationCoordinate2D){_lat, _lng}; 
MKCoordinateSpan span = (MKCoordinateSpan){0.2, 0.2}; 
MKCoordinateRegion region = (MKCoordinateRegion){coord, span}; 


[mapView setRegion:region]; 
[self.view addSubview:mapView]; 
+0

什麼是錯誤? –

+0

應用程序崩潰後第一行代碼 – ali

+0

崩潰報告????? –

回答

0

幾個問題:

  1. 的NSString * LAT =緯度;,什麼你的座位是否可以是CGFloat或其他類型?

  2. 您能打印您看到的錯誤消息嗎?

  3. 你使用調試器,它在哪一行代碼崩潰?我建議在以下位置放置一個斷點:NSString * lat = latitude;

  4. 您需要提供有關錯誤的更多信息(如果日誌中有任何內容)。 「給與你會收到」,這就是我的導師總是教給我的。提供更多信息,並且您將收到您想要的答案。