summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qioswindow.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-11-18 11:32:32 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-20 14:10:18 +0100
commit837228151d085264e8244969349b3d68d6f9cc94 (patch)
treebc80191009e16a992b7da903c4507cecdf672090 /src/plugins/platforms/ios/qioswindow.mm
parent49a3fe0cf8c8cddba6dacfb796e9db13c4ac74c6 (diff)
iOS: Don't keep around reference to a single QIOSViewController
We might have more of them in a multi-screen setup or when implementing support for modal windows using sub-viewcontrollers. Change-Id: Ibe98273a13af981fffe2704a2c05bfd9d3f3e9e0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios/qioswindow.mm')
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 3d1fe935e5..b13ce456a4 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -348,6 +348,16 @@
return nil;
}
+- (UIViewController *)viewController
+{
+ id responder = self;
+ while ((responder = [responder nextResponder])) {
+ if ([responder isKindOfClass:UIViewController.class])
+ return responder;
+ }
+ return nil;
+}
+
@end
QT_BEGIN_NAMESPACE
@@ -404,7 +414,7 @@ void QIOSWindow::setVisible(bool visible)
requestActivateWindow();
} else {
// Activate top-most visible QWindow:
- NSArray *subviews = qiosViewController().view.subviews;
+ NSArray *subviews = m_view.viewController.view.subviews;
for (int i = int(subviews.count) - 1; i >= 0; --i) {
UIView *view = [subviews objectAtIndex:i];
if (!view.hidden) {
@@ -460,7 +470,12 @@ void QIOSWindow::setParent(const QPlatformWindow *parentWindow)
UIView *parentView = reinterpret_cast<UIView *>(parentWindow->winId());
[parentView addSubview:m_view];
} else if (isQtApplication()) {
- [qiosViewController().view addSubview:m_view];
+ for (UIWindow *uiWindow in [[UIApplication sharedApplication] windows]) {
+ if (uiWindow.screen == static_cast<QIOSScreen *>(screen())->uiScreen()) {
+ [uiWindow.rootViewController.view addSubview:m_view];
+ break;
+ }
+ }
}
}