Google Maps Info window's resizing based on the internal content

心不动则不痛 提交于 2019-12-22 22:39:52

问题


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.

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

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

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

Internal UIScrollView attached via all 4 sides to base scrollview

internal UIScrollView attached to the top and left only

Sample test view hierarchy

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/30643740/google-maps-info-windows-resizing-based-on-the-internal-content

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