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>
This commit is contained in:
parent
f1970c8916
commit
f14d86c0f9
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user