[英]iOS how to start view controller for result before adding markers
我想創建視圖控制器以設置參數,然后再通過長時間單擊將GPS標記添加到google map上。 我從故事板創建的UI名稱為Main_iPhone.storyboard
下面是我的代碼:
-(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];
}
您可以在地圖上添加長按手勢,然后在手勢上調用代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.