2011-09-07 41 views
0

我一直在嘗試調用我已經存儲到數據庫中的地方的經度和緯度。我已經將存儲類型設置爲double。從核心數據調用座標

在第一個視圖控制器,我試圖推座標,並在日誌中工作正常。

-(IBAction) mapsend:(id)sender 
{ 
    DiscoverAllMapViewController *fvController = [[DiscoverAllMapViewController alloc] initWithNibName:@"DiscoverAllMapViewController" bundle:nil]; 
    [self.navigationController pushViewController:fvController animated:YES]; 
    double dx = [wher.latx doubleValue]; 
    double dy = [wher.longy doubleValue]; 

    fvController.latx =[NSString stringWithFormat:@"%f",dx]; 
    fvController.longy =[NSString stringWithFormat:@"%f",dy]; 
    NSLog(@"checking latx :%@",fvController.latx); 
    [fvController release]; 
} 

現在在DisplayAllMapViewController,日誌似乎總是爲空。我試着將解析實例設置爲NSString,NSNumber,double,但它仍然不發送任何值。

-(void)loadOurAnnotations 
{ 
    CLLocationCoordinate2D workingCoordinate; 
    MKCoordinateSpan span = {0.2, 0.2}; 
    double xx = [latx doubleValue]; 
    double yy = [longy doubleValue]; 
    NSLog(@"check latx :%f",xx); 
    workingCoordinate.latitude = xx; 
    workingCoordinate.longitude = yy; 
    MKCoordinateRegion region = {workingCoordinate, span}; 
    DiscoverAllMapAnnotation *appleStore1 = [[DiscoverAllMapAnnotation alloc] init]; 
    [appleStore1 setCoordinate:workingCoordinate]; 
    [appleStore1 setTitle:@"Kota Kinabalu"]; 
    [appleStore1 setSubtitle:@"BOMB!!!!!"]; 
    [appleStore1 setAnnotationType:DiscoverAllMapAnnotationType1]; 

    mapView.showsUserLocation=TRUE; 
    [mapView addAnnotation:appleStore1]; 
    [mapView setRegion:region]; 
    [appleStore1 release]; 


} 

請看看..謝謝

+0

什麼時候loadOurAnnotations被調用?在DisplayAllMapViewController的viewDidLoad中? – Anna

+0

@安娜卡列尼娜是的,在viewDidLoad – Harvin

回答

0

DiscoverAllMapViewControllerviewDidLoad只要你做pushViewController情況是你設置了latxlongy屬性之前。

pushViewController撥到的屬性被設置(就在fvController release之前)。