Google Maps Info窗口根据内部内容调整大小 [英] Google Maps Info window's resizing based on the internal content

查看:105
本文介绍了Google Maps Info窗口根据内部内容调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在基于UIStoryboard并使用自动版式使用此方法- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker创建自定义信息窗口.我预计某些内部视图将被调整大小,因为将接收到实际的文本信息,并且信息窗口的最终大小将与IB的视图不同.

I'm creating custom Info Window using this method - (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker based on the UIStoryboard using Autolayout. I expect that some of the internal views will be resized due to the actual text information will be received and the final size of the Info Window will be different from the view of IB.

实际上,结果是我的InfoWindow视图试图全屏显示,没有任何办法可以解决此问题.播放autoresizingMask不会改变任何东西,与设置Hugging Priority相同.唯一的方法是设置一个固定的大小约束,我这样做是为了宽度.但是对于身高,我需要根据内部内容的实际大小动态计算大小.

Actually, as the result my InfoWindow view tries to be full screen sized, and nothing helps to fix this. Playing with autoresizingMask doesn't change anything, the same result with setting Hugging Priority. The only way is to set a fixed size constraint, I've done this for width. But for height I need dynamically calculated size based on the real size of the internal content.

更新:从情节提要中添加了屏幕截图

UPDATE: Added screenshots from Storyboard

更新2 :具有2个滚动视图的示例测试,具有覆盖方法intrinsicContentSize:

UPDATE 2: Sample test with 2 scroll views, with overridden method intrinsicContentSize:

- (CGSize)intrinsicContentSize {
    [self layoutIfNeeded];
    return self.contentSize;
}

内部UIScrollView通过所有4个侧面附加到基本scrollview

Internal UIScrollView attached via all 4 sides to base scrollview

内部UIScrollView仅附加在顶部和左侧 示例测试视图层次结构

internal UIScrollView attached to the top and left only Sample test view hierarchy

如您所见,全屏根目录UIScrollView(蓝色边框)仍然存在.内部的UIScrollView(绿色)对此没有影响.它仍然具有全屏尺寸

As you can see full screen root UIScrollView (blue border) still exists. And internal UIScrollView (green color) has no influence on it. It's still has full screen size

推荐答案

不幸的是,我发现的唯一方法是使用显式框架,该框架需要手动计算,并且在Google Maps InfoWindow中完全不使用自动版式.

Unfortunately the only way I found is to use explicit frame, which needs to be calculated manually and do not use Autolayout at all with Google Maps InfoWindow.

我进行了一些测试,以验证同一视图如何显示为UIWindow的子视图,并发现其行为有所不同.

I made a couple of tests to verify how the same view displayed as the subview of UIWindow, and found that the behavior is different.

这篇关于Google Maps Info窗口根据内部内容调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆