Slava Slava - 5 months ago 31x
Swift Question

Delegate GMSMapView second time

My map works fine only at first time. This is how I declare it.

class ViewController: UIViewController, GMSMapViewDelegate {
@IBOutlet weak var GoogleMap: GMSMapView!

override func viewDidLoad() {

self.GoogleMap.delegate = self
let camera: GMSCameraPosition = GMSCameraPosition.cameraWithLatitude(55.755826, longitude: 37.6173, zoom: 9.0)
self.GoogleMap?.camera = camera

When I pass all screens of my app, and get back to the main screen with maps through Segue, all events which are connected to this maps don't work. The map still displays but it stops interacting with other elements on this screen.

I suppose it can be a problem with delegate, but I don't know how to solve it. I would like to hear any suggestions!


I solved this problem. I just didn't define my ViewController variable at the second time. There was incorrect condition.

if(vc==nil) {
    vc = self

So it didn't work second time, cause vc wasn't nil.