1

Ich bin neu in iOS-Anwendungsentwickler. Ich verwende die Google-Auswahlhilfe (GMSPlacePicker) und es sieht gut aus, aber nicht in der Suchleiste. Wie soll ich eine Suchleiste hinzufügen? Ich beziehe mich https://developers.google.com/places/ios-api/placepicker und sie stellen Dokumente auf https://developers.google.com/places/ios-api/autocomplete#add_an_autocomplete_ui_control zur Verfügung, aber ich bin verwirrt, wie man GMSAutocompleteViewController und GMSAutocompleteResultsViewController in Objective C implementiert. Kann mir bitte jemand helfen?Hinzufügen einer Suchleiste zu Google Place Picker (GMSPlacePicker)

Dank

+0

Sie können dieses Problem mit aktualisierten ** GoogleMaps.framework ** –

Antwort

1

ich das Problem gelöst haben. Ich habe gerade die GoogleMaps.framework aktualisieren.

2
- (IBAction)onLaunchClicked:(id)sender { 

    if ([_textField.text length] > 0) { 
     GMSAutocompleteViewController *acController = [[GMSAutocompleteViewController alloc] init]; 
     acController.delegate = self; 
     [self presentViewController:acController animated:YES completion:nil]; 
    }else { 
     UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Message" message:@"Enter a name" preferredStyle:UIAlertControllerStyleAlert]; 
     UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 

     }]; 
     [controller addAction:action]; 
     [self presentViewController:controller animated:YES completion:nil]; 
    } 
} 

// Handle the user's selection. 
- (void)viewController:(GMSAutocompleteViewController *)viewController 
didAutocompleteWithPlace:(GMSPlace *)place { 
    [self dismissViewControllerAnimated:YES completion:nil]; 
    // Do something with the selected place. 
    NSLog(@"Place name %@", place.name); 
    NSLog(@"Place address %@", place.formattedAddress); 
    NSLog(@"Place attributions %@", place.attributions.string); 

    [_peopleArray addObject:@{@"name":_textField.text, 
           @"place":place.name, 
           @"lat":[NSString stringWithFormat:@"%0.6f",place.coordinate.latitude], 
           @"long":[NSString stringWithFormat:@"%0.6f",place.coordinate.longitude]}]; 
    [_tableView reloadData]; 
    _textField.text = @""; 
} 

- (void)viewController:(GMSAutocompleteViewController *)viewController 
didAutocompleteWithError:(NSError *)error { 
    [self dismissViewControllerAnimated:YES completion:nil]; 
    // TODO: handle the error. 
    NSLog(@"Error: %@", [error description]); 
} 

// User canceled the operation. 
- (void)wasCancelled:(GMSAutocompleteViewController *)viewController { 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 
+0

Dank für den Kommentar @BhavukJain lösen –

Verwandte Themen