From 428eabdd60da8f0d70da0637ea58c46bfb9e7069 Mon Sep 17 00:00:00 2001 From: Fredrik Karlsson Date: Thu, 10 Nov 2016 15:49:17 +0100 Subject: [PATCH] [ios] update layout after device has been rotated --- platform/ios/src/MGLMapView.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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();