Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS如何在添加标记之前为结果启动视图控制器_Ios_Google Maps_Uiviewcontroller_Bundle - Fatal编程技术网

iOS如何在添加标记之前为结果启动视图控制器

iOS如何在添加标记之前为结果启动视图控制器,ios,google-maps,uiviewcontroller,bundle,Ios,Google Maps,Uiviewcontroller,Bundle,我想创建视图控制器来设置参数,然后在谷歌地图上长时间点击GPS标记。我从storyboard创建UI,名称为Main_iPhone.storyboard 以下是我的代码: -(void) mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate{ SliderViewController * object = [[SliderViewController alloc] i

我想创建视图控制器来设置参数,然后在谷歌地图上长时间点击GPS标记。我从storyboard创建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];

}

您可以在地图上添加长触摸手势,然后在手势上调用代码。调用视图后,确实加载了。

我已编辑了代码,但在执行时,背景色变为黑色。