未加载 mapViewDidLoad 方法 [英] mapViewDidLoad method not loaded
问题描述
目标 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.
推荐答案
确保 mapviewdelegate 通过右键单击 mapview 然后分配委托来连接.
make sure that mapviewdelegate is connected by right click on mapview and then assign delegate..
或添加[self.mapview setDelegate:self];
在您的情况下,AGSMapView" mapViewDidLoad:在将第一层添加到地图后调用 AGSMapViewLayerDelegate 上的方法.此时,该组件功能齐全,您可以在http://help.arcgis.com/en/arcgismobile/10.0/apis/iphone/reference/interface_a_g_s_map_view.html
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 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!