[英]MapView shows pin location and then disappears
我以前從未使用過Map-view,並且正在關注本教程
最后,我的模擬器在預期的位置顯示了預期的方式,但隨后立即變為藍屏。
藍屏仍在Google地圖中(它在底部顯示Google徽標),但不再是我要顯示的內容。
這是我的一些代碼:
- (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];
}
我能夠自己找到解決方案。 事實證明這很愚蠢。
我已經在MIBMapView的xib上打開了“顯示用戶位置”,這很干擾。 當我關閉它時,問題就消失了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.