2014-06-18 43 views
0

我想創建視圖控制器來設置參數,然後在Google地圖上長時間添加GPS標記。我創建故事板UI與名稱Main_iPhone.storyboardiOS如何在添加標記之前啓動視圖控制器結果

下面是我的代碼:

-(void) mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate{ 


SliderViewController * object = [[SliderViewController alloc] init]; 
[self presentViewController:object animated:YES completion:nil]; 




    //SliderViewController *secondView = [[SliderViewController alloc] initWithNibName:@"SliderViewController" bundle:[NSBundle mainBundle]]; 
    //[self.navigationController pushViewController:secondView animated:YES]; 



    CheckPoints *myCar=[[CheckPoints alloc] init]; 
    [myCar setState:0]; 
    [myCar setLatitude:coordinate.latitude]; 
    [myCar setLongitude:coordinate.longitude]; 
    NSString* theTextValue = @"Desitnation"; 
    [myCar setDesp:theTextValue]; 

    [array addObject:myCar]; 
    CheckPoints *lastChk = array.lastObject; 
    [self writeToTextFile:[NSString stringWithFormat:@"%@%@%@%@%@%@", lastChk.getDesp , @"\n",[NSString stringWithFormat:@"%f", lastChk.getLatitude], 
          @"\n", [NSString stringWithFormat:@"%f", lastChk.getLongitude], @"\n" ]]; 
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    [defaults setFloat:lastChk.getLatitude forKey:@"lati"]; 
    [defaults setFloat:lastChk.getLongitude forKey:@"longi"]; 
    [defaults setObject:lastChk.getDesp forKey:@"desp"]; 
    [defaults synchronize]; 

    for (int i = 0; i < [array count]; i++) { 
     CheckPoints *current = [array objectAtIndex:i]; 
     if(current.getLatitude != lastChk.getLatitude && current.getLongitude != lastChk.getLongitude){ 
      [current setState:1]; 
      NSString* previousTitle = [NSString stringWithFormat:@"%@%@", @"Checkpoint" ,[NSString stringWithFormat:@"%i", i+1]]; 
      [current setDesp:previousTitle]; 
     } 
    } 
    [self addMarkers]; 

} 

回答

0

您可以在地圖上添加長觸摸動作示意,然後調用你的代碼上gesture.after調用視圖確實加載。

+0

我編輯了代碼,但是當涉及到執行時,背景顏色變黑。 –

相關問題