[英]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. (例如,当我将
UILabel
或UIImage
添加到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上的子视图来测试笔尖,则它可以很好地与
UILabel
和UIImage
一起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.