path: root/src/plugins/platforms/ios/
diff options
authorRichard Moe Gustavsen <>2012-11-16 11:14:34 +0100
committerTor Arne Vestbø <>2013-02-27 23:55:46 +0100
commit55f0bce0945a2f2b28e2454fbc03b1efd61819e4 (patch)
treece656094925614213017de2051505404fb3ac455 /src/plugins/platforms/ios/
parent575d28a6fd62c83c82de5dfc0c34013948c0c9bd (diff)
iOS: implement requestWindowOrientation
The application is normally supposed to rotate the content on its own, but can call requestWindowOrientation to ask the window manager to do it instead. This way of integrating orientation with the OS is fragile, because: 1. In some cases, you cannot stop the OS from rotating at all (tablets). 2. It would be more safe to inform the window manager up-front which orientations it could rotate into, rather that relying on a function you call call to force this later on. 3. When the QML application starts, its a bit late to inform the platform plugin that it supports e.g landscape. If the OS is in landscape already, the plugin must still assume that the app operates in portrait (doing rotating on its own) until requestWindowOrientation is called. This might cause the app to first start up in portrait, just to rotate into landscape. On iOS, it seems like we can handle the first two cases. The third need some more investigation. We should anyway investigate if we need some adjustment to the Qt API. Change-Id: I50638b78d469ab70820a787de86a2f1981470786 Reviewed-by: Tor Arne Vestbø <>
Diffstat (limited to 'src/plugins/platforms/ios/')
1 files changed, 23 insertions, 3 deletions
diff --git a/src/plugins/platforms/ios/ b/src/plugins/platforms/ios/
index 5381b3a21e..8b1a085cc5 100644
--- a/src/plugins/platforms/ios/
+++ b/src/plugins/platforms/ios/
@@ -43,12 +43,32 @@
@implementation QIOSViewController
-- (BOOL)shouldAutorotate
- return NO;
+ self = [super init];
+ if (self) {
+ m_shouldAutorotate = NO;
+ }
+ return self;
-- (NSUInteger)supportedInterfaceOrientations
+ if ([UIViewController respondsToSelector:@selector(attemptRotationToDeviceOrientation)]) {
+ m_shouldAutorotate = YES;
+ [UIViewController attemptRotationToDeviceOrientation];
+ m_shouldAutorotate = NO;
+ return true;
+ }
+ return false;
+ return m_shouldAutorotate;
// We need to tell iOS that we support all orientations in order to set
// status bar orientation when application content orientation changes.