iOS: Update screen properties when we trigger statusbar changes on iOS7
Ideally we'd have a callback from iOS when this happens, so we can also react to changes done outside of Qt, but willChangeStatusBarFrame and friends do not seem to give us what we want. Change-Id: I686ce7950395a83c4257372363c773a95c3935ed Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
This commit is contained in:
parent
c5b19f2521
commit
9b782dca45
@ -189,6 +189,9 @@ void QIOSScreen::updateProperties()
|
||||
|
||||
void QIOSScreen::updateStatusBarVisibility()
|
||||
{
|
||||
if (!isQtApplication())
|
||||
return;
|
||||
|
||||
QWindow *focusWindow = QGuiApplication::focusWindow();
|
||||
|
||||
// If we don't have a focus window we leave the status
|
||||
@ -199,20 +202,26 @@ void QIOSScreen::updateStatusBarVisibility()
|
||||
return;
|
||||
|
||||
UIView *view = reinterpret_cast<UIView *>(focusWindow->handle()->winId());
|
||||
QIOSViewController *viewController = static_cast<QIOSViewController *>(view.viewController);
|
||||
|
||||
bool currentStatusBarVisibility = [UIApplication sharedApplication].statusBarHidden;
|
||||
if (viewController.prefersStatusBarHidden == currentStatusBarVisibility)
|
||||
return;
|
||||
|
||||
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0)
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) {
|
||||
[view.viewController setNeedsStatusBarAppearanceUpdate];
|
||||
[viewController setNeedsStatusBarAppearanceUpdate];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
updateProperties();
|
||||
});
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
bool wasHidden = [UIApplication sharedApplication].statusBarHidden;
|
||||
QIOSViewController *viewController = static_cast<QIOSViewController *>(view.viewController);
|
||||
[[UIApplication sharedApplication]
|
||||
setStatusBarHidden:[viewController prefersStatusBarHidden]
|
||||
withAnimation:UIStatusBarAnimationNone];
|
||||
|
||||
if ([UIApplication sharedApplication].statusBarHidden != wasHidden)
|
||||
updateProperties();
|
||||
updateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user