作者p81721 (Blue in HL)
看板MacDev
标题[问题] 地图定位
时间Sat Nov 3 22:05:40 2012
小弟在编写地图定位遇到一些瓶颈, 希望有大大可以帮忙解答
最近在研究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
1F:→ uranusjr:你期望要有什麽反应?你没动的话本来就什麽都不会发生啊 11/03 23:25