iOS: Don't use auto resizing masks to deal with maximized/fullscreen

It breaks down when the view-controller is fullscreen and we want to
take statusbar height into account as well. Unfortunately we can't
use constraints either, as it's iOS6+.

The approach of managing the geometry manually is closer to what
Android does as well.

Change-Id: Ib521ba0f50b110c440ab68aacef5a524d5d41154
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
bb10
Tor Arne Vestbø 2013-11-18 19:21:10 +01:00 committed by The Qt Project
parent ce6fd574b4
commit 16ad93af49
2 changed files with 21 additions and 11 deletions

View File

@ -180,6 +180,9 @@ void QIOSScreen::updateProperties()
m_availableGeometry = availableGeometry;
QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), m_availableGeometry);
}
if (screen())
resizeMaximizedWindows();
}
QRect QIOSScreen::geometry() const

View File

@ -448,19 +448,26 @@ void QIOSWindow::setWindowState(Qt::WindowState state)
// Perhaps setting QWindow to maximized should also mean that we'll show
// the statusbar, and vice versa for fullscreen?
if (state != Qt::WindowNoState)
m_normalGeometry = geometry();
switch (state) {
case Qt::WindowMaximized:
case Qt::WindowFullScreen: {
// Since UIScreen does not take orientation into account when
// reporting geometry, we need to look at the top view instead:
CGSize fullscreenSize = m_view.window.rootViewController.view.bounds.size;
m_view.frame = CGRectMake(0, 0, fullscreenSize.width, fullscreenSize.height);
m_view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
break; }
default:
m_view.frame = toCGRect(m_normalGeometry);
m_view.autoresizingMask = UIViewAutoresizingNone;
case Qt::WindowNoState:
setGeometry(m_normalGeometry);
break;
case Qt::WindowMaximized:
setGeometry(screen()->availableGeometry());
break;
case Qt::WindowFullScreen:
setGeometry(screen()->geometry());
break;
case Qt::WindowMinimized:
setGeometry(QRect());
break;
case Qt::WindowActive:
Q_UNREACHABLE();
default:
Q_UNREACHABLE();
}
}