diff options
author | Memphiz <memphis@machzwo.de> | 2014-10-05 14:22:59 +0200 |
---|---|---|
committer | Memphiz <memphis@machzwo.de> | 2014-10-23 09:54:59 +0200 |
commit | b5b00f7340dd75c756f5d2845f3745e1631a196a (patch) | |
tree | 56f187c3031653c5a43fa95ccaa39af6e6e9d8a6 | |
parent | 0f3db0516711e05765d297d060563730131c2f92 (diff) |
[ios8] - fix orientation bugs when compiling against ios 8.0 SDK (seems apple fixed
the 90 degree rotated display orientation since 8.0) - thx to mikrohard
-rw-r--r-- | xbmc/osx/IOSScreenManager.mm | 14 | ||||
-rw-r--r-- | xbmc/osx/ios/XBMCController.mm | 95 |
2 files changed, 76 insertions, 33 deletions
diff --git a/xbmc/osx/IOSScreenManager.mm b/xbmc/osx/IOSScreenManager.mm index ad2a7cb611..9ee1d6d110 100644 --- a/xbmc/osx/IOSScreenManager.mm +++ b/xbmc/osx/IOSScreenManager.mm @@ -244,11 +244,17 @@ static CEvent screenChangeEvent; res.size = [brwin interfaceFrame].size; #endif #else - //main screen is in portrait mode (physically) so exchange height and width - if(screen == [UIScreen mainScreen]) + #if __IPHONE_8_0 + if (CDarwinUtils::GetIOSVersion() < 8.0) + #endif { - CGRect frame = res; - res.size = CGSizeMake(frame.size.height, frame.size.width); + //main screen is in portrait mode (physically) so exchange height and width + //at least when compiled with ios sdk < 8.0 (seems to be fixed in later sdks) + if(screen == [UIScreen mainScreen]) + { + CGRect frame = res; + res.size = CGSizeMake(frame.size.height, frame.size.width); + } } #endif return res; diff --git a/xbmc/osx/ios/XBMCController.mm b/xbmc/osx/ios/XBMCController.mm index 9a32c0f9e0..e75585e295 100644 --- a/xbmc/osx/ios/XBMCController.mm +++ b/xbmc/osx/ios/XBMCController.mm @@ -48,6 +48,7 @@ #include "TextureCache.h" #undef id #include <math.h> +#include "osx/DarwinUtils.h" #ifndef M_PI #define M_PI 3.1415926535897932384626433832795028842 @@ -326,25 +327,29 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL; //-------------------------------------------------------------- - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { - orientation = toInterfaceOrientation; - CGRect srect = [IOSScreenManager getLandscapeResolution: [m_glView getCurrentScreen]]; - CGRect rect = srect;; - - - switch(toInterfaceOrientation) +#if __IPHONE_8_0 + if (CDarwinUtils::GetIOSVersion() < 8.0) +#endif { - case UIInterfaceOrientationPortrait: - case UIInterfaceOrientationPortraitUpsideDown: - if(![[IOSScreenManager sharedInstance] isExternalScreen]) - { - rect.size = CGSizeMake( srect.size.height, srect.size.width ); - } - break; - case UIInterfaceOrientationLandscapeLeft: - case UIInterfaceOrientationLandscapeRight: - break;//just leave the rect as is - } - m_glView.frame = rect; + orientation = toInterfaceOrientation; + CGRect srect = [IOSScreenManager getLandscapeResolution: [m_glView getCurrentScreen]]; + CGRect rect = srect;; + + switch(toInterfaceOrientation) + { + case UIInterfaceOrientationPortrait: + case UIInterfaceOrientationPortraitUpsideDown: + if(![[IOSScreenManager sharedInstance] isExternalScreen]) + { + rect.size = CGSizeMake( srect.size.height, srect.size.width ); + } + break; + case UIInterfaceOrientationLandscapeLeft: + case UIInterfaceOrientationLandscapeRight: + break;//just leave the rect as is + } + m_glView.frame = rect; + } } - (UIInterfaceOrientation) getOrientation @@ -744,22 +749,31 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL; name: nil object: nil]; - /* We start in landscape mode */ - CGRect srect = frame; - srect.size = CGSizeMake( frame.size.height, frame.size.width ); orientation = UIInterfaceOrientationLandscapeLeft; + +#if __IPHONE_8_0 + if (CDarwinUtils::GetIOSVersion() < 8.0) +#endif + { + /* We start in landscape mode */ + CGRect srect = frame; + // in ios sdks older then 8.0 the landscape mode is 90 degrees + // rotated + srect.size = CGSizeMake( frame.size.height, frame.size.width ); - m_glView = [[IOSEAGLView alloc] initWithFrame: srect withScreen:screen]; - [[IOSScreenManager sharedInstance] setView:m_glView]; - [m_glView setMultipleTouchEnabled:YES]; + m_glView = [[IOSEAGLView alloc] initWithFrame: srect withScreen:screen]; + [[IOSScreenManager sharedInstance] setView:m_glView]; + [m_glView setMultipleTouchEnabled:YES]; - /* Check if screen is Retina */ - screenScale = [m_glView getScreenScale:screen]; + /* Check if screen is Retina */ + screenScale = [m_glView getScreenScale:screen]; - [self.view addSubview: m_glView]; + [self.view addSubview: m_glView]; - [self createGestureRecognizers]; - [m_window addSubview: self.view]; + [self createGestureRecognizers]; + [m_window addSubview: self.view]; + } + [m_window makeKeyAndVisible]; g_xbmcController = self; @@ -768,6 +782,29 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL; return self; } //-------------------------------------------------------------- +#if __IPHONE_8_0 +- (void)loadView +{ + [super loadView]; + if (CDarwinUtils::GetIOSVersion() >= 8.0) + { + self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.view.autoresizesSubviews = YES; + + m_glView = [[IOSEAGLView alloc] initWithFrame:self.view.bounds withScreen:[UIScreen mainScreen]]; + [[IOSScreenManager sharedInstance] setView:m_glView]; + [m_glView setMultipleTouchEnabled:YES]; + + /* Check if screen is Retina */ + screenScale = [m_glView getScreenScale:[UIScreen mainScreen]]; + + [self.view addSubview: m_glView]; + + [self createGestureRecognizers]; + } +} +#endif +//-------------------------------------------------------------- -(void)viewDidLoad { [super viewDidLoad]; |