3

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

enter image description here

enter image description here

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 via all 4 sides to base scrollview

internal UIScrollView attached to the top and left only internal UIScrollView attached to the top and left only Sample test view hierarchy 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

skyylex
  • 855
  • 1
  • 10
  • 24
  • Can you post your code / storyboard screenshot? – Asaf Jun 04 '15 at 12:50
  • 1
    For height, you need to set the `vertical spacing` (both top and bottom) between your labels and the `UIView`. if you have too many labels in your `UIView`, you should consider use `UIScrollView` instead. – ztan Jun 04 '15 at 16:25
  • ztan, good idea, unfortunately doesn't solve the problem. See UPDATE 2 – skyylex Jun 04 '15 at 18:29

1 Answers1

5

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.

skyylex
  • 855
  • 1
  • 10
  • 24
  • Interesting discovery. I suspect this may be a source of troubles I'm facing with a custom UIView for the marker itself. For now I'll be following your advice and sizing manually. – Joe May 04 '16 at 20:04