0

I'm working on an iOS application that has a UIViewController whose view has a MapView as a subview. However, when I run the application and try to rotate the view in the simulator, it doesn't work as it should; it leaves a black box as shown:

Original View

Rotated View

How can I tell the MapView to resize along with its superview?

Jake Sebright
  • 799
  • 8
  • 16
  • Do you have any constraints or autoresizing masks set up? Your map needs to know how to resize itself when it's superview changes size – dan Apr 27 '16 at 22:58
  • My MapView is a subview of the UIViewController's view. How can I tell the map how to resize itself when the superview changes size? – Jake Sebright Apr 27 '16 at 23:04

1 Answers1

1

Try to use this code

ObjC

yourMapView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin |
                               UIViewAutoresizingFlexibleLeftMargin |
                               UIViewAutoresizingFlexibleBottomMargin;

Swift

yourMapView.autoresizingMask = [.FlexibleRightMargin, .FlexibleLeftMargin, .FlexibleBottomMargin]
Evgeny Karkan
  • 8,782
  • 2
  • 32
  • 38