diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 39f243f57cc..7b0ea2e560a 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -533,6 +533,11 @@ - (void)commonInit [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wakeGL:) name:UIApplicationWillEnterForegroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wakeGL:) name:UIApplicationDidBecomeActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; + +#if !TARGET_OS_TVOS + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil]; + [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; +#endif // set initial position // @@ -639,6 +644,9 @@ - (void)reachabilityChanged:(NSNotification *)notification - (void)dealloc { +#if !TARGET_OS_TVOS + [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; +#endif [[NSNotificationCenter defaultCenter] removeObserver:self]; [_attributionButton removeObserver:self forKeyPath:@"hidden"]; @@ -1064,6 +1072,11 @@ - (void)didMoveToSuperview [super didMoveToSuperview]; } +- (void)deviceOrientationDidChange:(__unused NSNotification *)notification +{ + [self setNeedsLayout]; +} + - (void)sleepGL:(__unused NSNotification *)notification { MGLAssertIsMainThread();