我以前从未使用过地图视图,我正在关注本教程
最后,我的模拟器以应有的方式显示该点,在应有的位置,但随后立即变为蓝屏。
蓝屏仍在谷歌地图中(它在底部显示谷歌徽标)但它不再是我想要显示的内容。
这是我的一些代码:
- (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];
}