我在尝试使用iOS 7 beta中提供的MKTileOverlay和MKTileOverlayRenderer来在苹果地图视图上添加Mapbox瓦片图层或Mapbox服务器地图。我将自己的信息放入了一些在线示例代码中,以加载一个地图视图上的服务器地图,但它创建了一个错误,我需要一些帮助来解释。我得到了这个错误:使用未声明的标识符“overlay”。
//.h
@property (strong, nonatomic) IBOutlet MKMapView *mapView;
//.m
NSString *template = @"jbailo.Lighting/tile?z={z}&x={x}&y={y}";
overlay = [[MKTileOverlay alloc ] initWithURLTemplate:template];
overlay.canReplaceMapContent = YES;
[_mapView addOverlay:overlay level:MKOverlayLevelAboveRoads];
-(MKTileOverlayRenderer *)mapView:(MKMapView*)mapView rendererForOverlay:(id<MKOverlay>)overlay {
return [[MKTileOverlayRenderer alloc] initWithOverlay:overlay];
}
请告诉我应该将overlay声明为什么,如果有人使用这些tileOverlays方法的经验,请随时给予建议和建议。
overlay
?看一下template
是如何声明为NSString *template
,而mapView
则是声明为MKMapView *mapView
的。 - Craig