问题描述
目标c的新功能,我正在使用ArcGIS作为地图部分。我有一个问题,没有调用/加载方法 mapViewDidLoad
。以下是代码的一部分:
New to objective c, and I am using ArcGIS for the map portion. I have a problem where the method mapViewDidLoad
is not called/loaded. Here is some part of the code:
.h文件
@interface ViewController : UIViewController<AGSMapViewLayerDelegate, AGSMapViewTouchDelegate, AGSMapViewCalloutDelegate>{
AGSMapView *_mapView;
AppDelegate *appDelegate;
...
}
.m文件
- (void)viewDidLoad
{
[super viewDidLoad];
[self.activityView startAnimating];
self.mapView.touchDelegate = self;
self.mapView.calloutDelegate = self;
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
...
}
- (void)mapViewDidLoad:(AGSMapView *)mapView {
AGSEnvelope *envelope = [[AGSEnvelope alloc]initWithXmin:29757.610204117
ymin:40055.0379682464
xmax:29884.6992302249
ymax:40236.6028660071
spatialReference:self.mapView.spatialReference];
[self.mapView zoomToEnvelope:envelope animated:YES];
self.mapView.callout.width = 195.0f;
self.mapView.callout.accessoryButtonHidden = YES;
[self.mapView.gps start];
[self.mapView centerAtPoint:self.mapView.gps.currentPoint animated:YES];
NSLog(@"Location : %@", self.mapView.gps.currentPoint);
[self.activityView stopAnimating];
self.activityView.hidden = YES;
}
我的代码有什么问题我为什么不加载 mapViewDidLoad
方法。
提前致谢。
What is wrong with my code why i doesn't load the mapViewDidLoad
method.Thanks in advance.
推荐答案
确保通过右键单击mapview连接mapviewdelegate,然后分配委托。
make sure that mapviewdelegate is connected by right click on mapview and then assign delegate..
或添加 [self.mapview setDelegate:self];
在您的情况下AGSMapViewmapViewDidLoad:AGSMapViewLayerDelegate上的方法是在将第一个图层添加到地图后调用。此时,该组件功能齐全,您可以在
中找到对它的引用
in your case "AGSMapView" mapViewDidLoad: method on AGSMapViewLayerDelegate is invoked after the first layer has been added to the map. At this point, the component is fully functional you can find reference to it in http://help.arcgis.com/en/arcgismobile/10.0/apis/iphone/reference/interface_a_g_s_map_view.html
make self.mapview.layerDelegate = self;
make self.mapview.layerDelegate = self;
这篇关于mapViewDidLoad方法未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!