简体   繁体   English

在Google地图上加载标记的自定义信息窗口时,iOS应用程序冻结

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

I am trying to implement a custom info window on my Google Maps Marker on an iOS app. 我正在尝试在iOS应用程序的Google Maps Marker上实现自定义信息窗口。 (As is done here and here for example.) (例如, 这里这里完成操作。)

I have created a xib and a UIView class for it. 我已经为其创建了一个xib和一个UIView类。 It is called CustomInfoWindow.xib and the class is CustomInfoWindow.swift . 它称为CustomInfoWindow.xib ,其类为CustomInfoWindow.swift

My Custom Info Window is currently blank, ie I have not yet added any UIControl s to my xib. 我的“定制信息窗口”当前为空白,即我尚未将任何UIControl添加到我的xib中。 I have also not yet added any code to my class file. 我还没有在班级文件中添加任何代码。

The CustomInfoWindow.swift file basically looks like: CustomInfoWindow.swift文件基本上如下所示:

import UIKit
class CustomInfoWindow: UIView {}

In my ViewController for my maps my markerInfoWindow method is as follows: 在我的地图的ViewController中,我的markerInfoWindow方法如下:

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. 当我运行代码并单击其中一个标记时,空白的CustomInfoWindow显示正常。

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. 奇怪的是,当我在Interface Builder中将任何UI元素添加到CustomInfoWindow.xib并再次运行我的应用程序时,然后当我单击应用程序冻结的标记时突然运行。 (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. (例如,当我将UILabelUIImage添加到CustomInfoWindow.xib 。)如果删除UI元素,则空白笔尖在标记上显示良好。

If I test my nib by adding it as a subview on some View Controller then it loads fine with my UILabel and UIImage . 如果我通过将笔尖添加为某个View Controller上的子视图来测试笔尖,则它可以很好地与UILabelUIImage一起UILabel However, when I use that same nib in the markerInfoWindow the app freezes. 但是,当我在markerInfoWindow使用相同的笔尖时,应用程序冻结。

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 . 更新:此问题发生在iOS版Google Maps SDK 1.13版上,事实证明是该版本上错误

I have the same issue. 我有同样的问题。 It's a GoogleMaps's bug! 这是GoogleMaps的错误! Freezing apperrs in version 1.13.0. 在1.13.0版中冻结apperrs。

You can use: 您可以使用:

pod 'GoogleMaps', '1.12.3'

Found the proper workaround for 1.13 找到适合1.13的解决方法

Add the following code to the subclass CustomInfoWindow 将以下代码添加到CustomInfoWindow子类中

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Maps SDK iOS - 带UIButton的自定义标记信息窗口 - Google Maps SDK iOS - Custom marker info window with UIButton IOS谷歌地图sdk中的自定义信息窗口 - Custom info window in IOS google maps sdk Google Maps在标记信息窗口iOS中显示语音气泡 - Google Maps Showing speechbubble in marker info window iOS 以编程方式谷歌地图iOS的标记的关闭信息窗口 - Close info window of a marker programmatically google maps iOS 如何在不点击标记的情况下在 iOS 谷歌地图中显示信息窗口? - How to show a Info window in iOS Google maps without tapping on Marker? Xamarin.iOS上的自定义Google Maps标记信息视图 - Custom Google Maps marker info view on Xamarin.iOS 在实现 mapView:didTapMarker 时在谷歌地图 iOS sdk 中点击标记时显示信息窗口:已实现委托方法 - Displaying info window when tapped marker in google maps iOS sdk while implementing mapView:didTapMarker: delegate method implemented 使用Google Maps iOS SDK快速创建自定义信息窗口? - Creating custom info window in swift with the Google maps iOS sdk? 适用于iOS的Google Maps APi:自定义信息窗口上的UIActivityView - Google Maps APi for iOS: UIActivityView on custom info window 当我使用自定义图标时,谷歌地图ios如何不显示信息窗口? - How come with google maps ios the info window isn't showing when I use a custom Icon?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM