iOS app freezes when loading custom info window for marker on Google Maps

淺唱寂寞╮ 提交于 2019-12-04 00:57:24

问题


I am trying to implement a custom info window on my Google Maps Marker on an iOS app. (As is done here and here for example.)

I have created a xib and a UIView class for it. It is called CustomInfoWindow.xib and the class is CustomInfoWindow.swift.

My Custom Info Window is currently blank, i.e. I have not yet added any UIControls to my xib. I have also not yet added any code to my class file.

The CustomInfoWindow.swift file basically looks like:

import UIKit
class CustomInfoWindow: UIView {}

In my ViewController for my maps my markerInfoWindow method is as follows:

func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {
    let customInfoWindow = NSBundle.mainBundle().loadNibNamed("CustomInfoWindow", owner: self, options: nil)[0] as! CustomInfoWindow

    return customInfoWindow
}

When I run the code and I click on one of my markers, the blank CustomInfoWindow displays fine.

The strange thing is that the moment I add any UI Element to the CustomInfoWindow.xib in the Interface Builder and run my app again then suddenly when I click on a marker the app freezes. (For example when I add a UILabel or a UIImage to the CustomInfoWindow.xib.) If I remove the UI Element then the blank nib displays fine over the marker.

If I test my nib by adding it as a subview on some View Controller then it loads fine with my UILabel and UIImage. However, when I use that same nib in the markerInfoWindow the app freezes.

What can the problem be?

UPDATE: This issue occurred on version 1.13 of the Google Maps SDK for iOS and it turned out to be a bug on that version.


回答1:


I have the same issue. It's a GoogleMaps's bug! Freezing apperrs in version 1.13.0.

You can use:

pod 'GoogleMaps', '1.12.3'



回答2:


Found the proper workaround for 1.13

Add the following code to the subclass CustomInfoWindow

override func didMoveToSuperview() {
        superview?.autoresizesSubviews = false;
}

Source: https://code.google.com/p/gmaps-api-issues/issues/detail?id=9525



来源:https://stackoverflow.com/questions/36746786/ios-app-freezes-when-loading-custom-info-window-for-marker-on-google-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!