2012-08-06 39 views
1

新增目標c,我將ArcGIS用於地圖部分。我有一個問題,方法mapViewDidLoad未被調用/加載。下面是代碼的某些部分: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方法。 在此先感謝。

+0

請確保您使mapview連接到插座並使其成爲委託=自我是文件擁有者在您的情況下 – 2012-08-06 07:28:35

+0

yup出口mapView已經連接到文件所有者。我的每個插座都連接到他們的適當位置 – sihao 2012-08-06 07:31:13

+0

並且mapview的代理也被分配給fileowner仔細檢查此步驟 – 2012-08-06 07:32:24

回答

0

添加self.mapView.delegate = self;確保mapviewdelegate通過右鍵點擊連接在MapView的,然後分配委託.. enter image description here

或你的情況 「AGSMapView」 mapViewDidLoad添加[self.mapview setDelegate:self];

:AGSMapViewLayerDelegate方法在第一層添加到地圖後調用。在這一點上,該組件功能齊全,你可以在 http://help.arcgis.com/en/arcgismobile/10.0/apis/iphone/reference/interface_a_g_s_map_view.html

make self.mapview.layerDelegate = self;

+0

我沒有代理插座部分,我添加了'[self.mapview setDelegate:self];'它給了我一個警告''AGSMapView'可能不會迴應到'setDelegate',它在運行時崩潰,'終止應用程序,由於未捕獲異常'NSInvalidArgumentException',原因:' - [AGSMapView setDelegate:]:無法識別的選擇器發送到實例0x90afc00'' – sihao 2012-08-06 07:46:26

+0

嘗試[self.mapview setAGSMapViewDelegate:self] ; – 2012-08-06 07:58:02

+0

也適用於self.mapview.mapViewDelegate = self – 2012-08-06 07:59:48

0

就在viewDidLoad

+0

如果我添加此「Property」委託'沒有在'AGSMapView *'類型的對象上找到' – sihao 2012-08-06 07:39:28