Pregunta

Lo que hago en mi aplicación está siguiendo:

Cargo algunos datos en los datos del núcleo y cuando se termina las necesidades de la aplicación para Segue a la siguiente vista (Google MAP)

[self performSegueWithIdentifier:@"loadMap" sender:self];

pero obtengo este error

Terminating app due to uncaught exception 'GMSThreadException', reason: 'All calls to the Google Maps SDK for iOS must be made from the UI thread'

Si hago todo esto, pero hago un segue con un botón en un botón, todo funciona bien.

Google Map View Controller en Storyboard tiene una salida de vista GMSMAPVVIEW con código de inicio

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:45.331875
                                                            longitude:14.450455
                                                                 zoom:14];

    self.mapView.camera = camera;

    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = camera.target;
    marker.title = @"Test title";
    marker.snippet = @"Lorem ipsum...";
    marker.map = self.mapView;

¿Alguien puede ayudarme aquí?¿Cómo puedo cargar el controlador de la vista con Google Maps programáticamente usando Storyboard?

¿Fue útil?

Solución

La excepción parece estar indicando que está intentando realizar un segue en el hilo de fondo.Para evitar que se estrelló, debe usar el hilo principal en su lugar.Envuelva su performSegueWithIdentifier:sender: de la siguiente manera para usar el hilo principal:

dispatch_async(dispatch_get_main_queue(), ^{
    [self performSegueWithIdentifier:@"loadMap" sender:self];
});

Otros consejos

para SWIFT:

dispatch_async(dispatch_get_main_queue(), {})

Tirar el código en esos curlos ...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top