Iphone 地图视图显示接点位置,然后消失
我以前从未使用过地图视图,我一直在学习教程 最后,我的模拟器以它应该的方式在它应该的位置显示该点,但随后立即变为蓝屏 蓝色屏幕仍然在谷歌地图中(它在底部显示谷歌标志),但它不再是我想要显示的 以下是我的一些代码:Iphone 地图视图显示接点位置,然后消失,iphone,ios,maps,Iphone,Ios,Maps,我以前从未使用过地图视图,我一直在学习教程 最后,我的模拟器以它应该的方式在它应该的位置显示该点,但随后立即变为蓝屏 蓝色屏幕仍然在谷歌地图中(它在底部显示谷歌标志),但它不再是我想要显示的 以下是我的一些代码: - (void)viewDidLoad { HandbookAppDelegate *delegate = (HandbookAppDelegate *)[[UIApplication sharedApplication] delegate]; Rule *thi
- (void)viewDidLoad
{
HandbookAppDelegate *delegate = (HandbookAppDelegate *)[[UIApplication sharedApplication] delegate];
Rule *thisRule = [delegate.rules objectAtIndex:index.row];
self.title = thisRule.ruleNumber;
// Set some coordinates for our position (Buckingham Palace!)
CLLocationCoordinate2D location;
location.latitude = (double) 51.501468;
location.longitude = (double) -0.141596;
// Add the annotation to our map view
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Buckingham Palace" andCoordinate:location];
[self.map addAnnotation:newAnnotation];
[newAnnotation release];
}
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView = [views objectAtIndex:0];
id <MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 1500, 1500);
[mv setRegion:region animated:YES];
[mv selectAnnotation:mp animated:YES];
}
-(void)viewDidLoad
{
HandbookAppDelegate*委托=(HandbookAppDelegate*)[[UIApplication sharedApplication]委托];
Rule*thisRule=[delegate.rules objectAtIndex:index.row];
self.title=thisRule.ruleNumber;
//为我们的位置设置一些坐标(白金汉宫!)
CLLOCATION坐标2D定位;
位置纬度=(双)51.501468;
位置经度=(双)-0.141596;
//将注释添加到地图视图中
MapViewAnnotation*newAnnotation=[[MapViewAnnotation alloc]initWithTitle:@“白金汉宫”和坐标:位置];
[self.map addAnnotation:newAnnotation];
[新注释发布];
}
-(void)地图视图:(MKMapView*)mv DIDADDAnnotationView:(NSArray*)视图
{
MKAnnotationView*annotationView=[views objectAtIndex:0];
id mp=[annotationView注释];
mkcoordinaereregion=mkcoordinaereregionmakewithdistance([mp坐标],15001500);
[mv setRegion:区域动画:是];
[mv selectAnnotation:mp动画:是];
}
我能够自己发现解决方案。结果证明这是相当愚蠢的
我已经为MKMapView打开了xib上的“显示用户位置”,所以这是干扰。当我关掉它时,问题就消失了