summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2014-07-28 16:24:11 +0200
committerTor Arne Vestbø <tor.arne.vestbo@digia.com>2014-09-24 11:53:14 +0200
commitf14d86c0f9fee9e5c52a5d1e857eb19c93cfed7e (patch)
tree9cff914dc8f1bb0612527b9aa3fd5901a7f6eef0 /src/plugins
parentf1970c89169ed04250f789bec589deb2813c955d (diff)
iOS: Reflect changes in statusbar height as QScreen availableGeometry
We detect changes to the statusbar height, eg. when the in-call 40px tall statusbar is active, and ensure that the root viewcontroller view is laid out again with new screen properties applied. To make the layout match the animation of the statusbar height we apply the layout inside a animation block. Change-Id: I751d9d1273e833ef052a3a4f3d2777e1dffec7dd Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.mm36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm
index 7079cd73eb..9a5d5c3691 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.mm
+++ b/src/plugins/platforms/ios/qiosviewcontroller.mm
@@ -155,6 +155,22 @@
self.view = [[[QIOSDesktopManagerView alloc] init] autorelease];
}
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+ [center addObserver:self selector:@selector(willChangeStatusBarFrame:)
+ name:UIApplicationWillChangeStatusBarFrameNotification
+ object:[UIApplication sharedApplication]];
+}
+
+- (void)viewDidUnload
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:nil];
+ [super viewDidUnload];
+}
+
-(BOOL)shouldAutorotate
{
// Until a proper orientation and rotation API is in place, we always auto rotate.
@@ -179,6 +195,26 @@
}
#endif
+- (void)willChangeStatusBarFrame:(NSNotification*)notification
+{
+ Q_UNUSED(notification);
+
+ if (self.view.window.screen != [UIScreen mainScreen])
+ return;
+
+ // UIKit doesn't have a delegate callback for statusbar changes that's run inside the
+ // animation block, like UIViewController's willAnimateRotationToInterfaceOrientation,
+ // nor does it expose a constant for the duration and easing of the animation. However,
+ // though poking at the various UIStatusBar methods, we can observe that the animation
+ // uses the default easing curve, and runs with a duration of 0.35 seconds.
+ static qreal kUIStatusBarAnimationDuration = 0.35;
+
+ [UIView animateWithDuration:kUIStatusBarAnimationDuration animations:^{
+ [self.view setNeedsLayout];
+ [self.view layoutIfNeeded];
+ }];
+}
+
- (void)viewWillLayoutSubviews
{
if (!QCoreApplication::instance())