未加载mapViewDidLoad方法(mapViewDidLoad method not load

2019-07-30 19:29发布

的新目标c和我使用ArcGIS的地图部分。 我有一个在方法问题mapViewDidLoad不叫/加载。 下面是代码的某些部分:

.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方法。 提前致谢。

Answer 1:

确保mapviewdelegate通过在MapView的右键点击连接,然后指定代理..

或添加[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

使self.mapview.layerDelegate =自我;



Answer 2:

只需添加self.mapView.delegate = self;viewDidLoad



文章来源: mapViewDidLoad method not loaded