spacefractal · 53645
- (void)setActive:(BOOL)value{ m_active = value; if (m_active) { [self becomeFirstResponder]; } else { [self resignFirstResponder]; }}- (void)didEnterBackground{ if (self.active) [self resignFirstResponder];}- (void)didBecomeActive{ if (self.active) [self becomeFirstResponder];}- (BOOL)canBecomeFirstResponder{ return YES;}
Rotation and Orientation fixes – A multitude of fixes are in iOS 8.3 for performance slowdowns related to app rotation and also orientation problems where devices fail to recognise which way they are being held or lock in one orientation.
int iPhoneSETORIENTATION(int orig) { if(orig==-1) { if (nrewrotation==0) return 0; [gpimainView setActive:YES]; if (UIInterfaceOrientationLandscapeLeftSupported==YES || UIInterfaceOrientationLandscapeRightSupported==YES) { printf("islandscape, "); if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { printf("0\n"); return 0; } printf("1\n"); return 1; } printf("0\n"); return 0; } if(orig==0) { [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationPortraitUpsideDown] forKey:@"orientation"]; printf("UIInterfaceOrientationPortraitUpsideDown\n"); } } if(orig==1) { [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight]; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { [[UIDevice currentDevice//] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"]; printf("UIDeviceOrientationLandscapeLeft\n"); } } if(orig==2) { [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortraitUpsideDown]; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"]; printf("UIDeviceOrientationPortrait\n"); } } if(orig==3) { [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft]; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeRight] forKey:@"orientation"]; printf("UIDeviceOrientationLandscapeRight\n"); } } return orig;}
-(CGRect)boundsForOrientation{ UIScreen *screen = [UIScreen mainScreen]; CGRect screenRect; if (![screen respondsToSelector:@selector(fixedCoordinateSpace)] && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) { printf("boundsForOrientation 1 ok\n"); screenRect = CGRectMake(screen.bounds.origin.x, screen.bounds.origin.y, screen.bounds.size.height, screen.bounds.size.width); } else { printf("boundsForOrientation 2 ok\n"); screenRect = screen.bounds; printf("x: %f", screen.bounds.origin.x); printf(" y: %f", screen.bounds.origin.y); printf(" w: %f", screen.bounds.size.width); printf(" h: %f", screen.bounds.size.height); printf("\n"); } return screenRect;}
- (void)rotateView:(UIInterfaceOrientation) orientation{ CGSize screenSize = [[UIScreen mainScreen] bounds].size; //DEBUGLOG("UIRotateView width: %.f height: %.f", screenSize.width, screenSize.height); if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { if (screenSize.width > screenSize.height && UIInterfaceOrientationIsPortrait(orientation)) screenSize = CGSizeMake(screenSize.height, screenSize.width); else if (screenSize.height > screenSize.width && UIInterfaceOrientationIsLandscape(orientation)) screenSize = CGSizeMake(screenSize.height, screenSize.width); } else screenSize = UIInterfaceOrientationIsPortrait(orientation) ? CGSizeMake(screenSize.height, screenSize.width) : screenSize; self.bounds = IS_IPAD() ? CGRectMake(0, 0, 480, screenSize.height - 56) : CGRectMake(0, 0, screenSize.width, screenSize.height); self.center = CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2); //CGRect toolBarFrame = self.toolBar.frame; //toolBarFrame.size.width = self.bounds.size.width; //self.toolBar.frame = toolBarFrame; ; DEBUGLOG("[%s] UIRotateView width: %.f height: %.f (%s)", [NSStringFromClass([self class]) UTF8String], screenSize.width, screenSize.height, UIInterfaceOrientationIsPortrait(orientation) ? "Portrait" : "Landscape"); #if AUTOROTATE_MODE == 0 self.center = CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2); self.transform = CGAffineTransformIdentity; switch (orientation) { case UIInterfaceOrientationPortrait: self.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(0)); break; case UIInterfaceOrientationLandscapeRight: self.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90)); break; case UIInterfaceOrientationPortraitUpsideDown: self.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(180)); break; case UIInterfaceOrientationLandscapeLeft: self.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-90)); break; default: break; }#endif}
-(CGRect)boundsForOrientation{ int orientation=1; // not the correct way to do for enduser, but this is just a orintation test. CGSize screenSize = [[UIScreen mainScreen] bounds].size; //DEBUGLOG("UIRotateView width: %.f height: %.f", screenSize.width, screenSize.height); if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { if (screenSize.width > screenSize.height && UIInterfaceOrientationIsPortrait(orientation)) screenSize = CGSizeMake(screenSize.height, screenSize.width); else if (screenSize.height > screenSize.width && UIInterfaceOrientationIsLandscape(orientation)) screenSize = CGSizeMake(screenSize.height, screenSize.width); } else screenSize = UIInterfaceOrientationIsPortrait(orientation) ? CGSizeMake(screenSize.height, screenSize.width) : screenSize; CGRect screenRect = CGRectMake(0, 0, screenSize.width, screenSize.height); return screenRect;}
self.center = CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2);
-(CGRect)boundsForOrientation{ int orientation=1;// if (UIInterfaceOrientationLandscapeLeftSupported == YES) orientation=1;// if (UIInterfaceOrientationLandscapeRightSupported == YES) orientation=3; CGSize screenSize = [[UIScreen mainScreen] bounds].size; //DEBUGLOG("UIRotateView width: %.f height: %.f", screenSize.width, screenSize.height); if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { if (screenSize.width > screenSize.height && UIInterfaceOrientationIsPortrait(orientation)) screenSize = CGSizeMake(screenSize.height, screenSize.width); else if (screenSize.height > screenSize.width && UIInterfaceOrientationIsLandscape(orientation)) screenSize = CGSizeMake(screenSize.height, screenSize.width); } else screenSize = UIInterfaceOrientationIsPortrait(orientation) ? CGSizeMake(screenSize.height, screenSize.width) : screenSize; CGRect screenRect = CGRectMake(0, 0, screenSize.width, screenSize.height); return screenRect;}
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { if(UIInterfaceOrientationLandscapeLeftSupported == YES || UIInterfaceOrientationLandscapeRightSupported == YES) { int l=bounds.size.width-bounds.size.height; window.center = CGPointMake(bounds.size.width/2, bounds.size.height/2+l); } }
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectRotation) name:UIDeviceOrientationDidChangeNotification object:nil];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
- (void)detectRotation{ UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation]; UIInterfaceOrientation interfaceOrienation; //DEBUGLOG("EAGLView detectRotation - ORIENTATION %d", interfaceOrienation ); if(!UIDeviceOrientationIsValidInterfaceOrientation(deviceOrientation)) return; switch(deviceOrientation) { case UIDeviceOrientationUnknown: case UIDeviceOrientationFaceUp: case UIDeviceOrientationFaceDown: break; case UIDeviceOrientationPortrait: interfaceOrienation = UIInterfaceOrientationPortrait; break; case UIDeviceOrientationPortraitUpsideDown: interfaceOrienation = UIInterfaceOrientationPortraitUpsideDown; break; case UIDeviceOrientationLandscapeRight: interfaceOrienation = UIInterfaceOrientationLandscapeLeft; break; case UIDeviceOrientationLandscapeLeft: interfaceOrienation = UIInterfaceOrientationLandscapeRight; break; } [self rotateView:interfaceOrienation];}
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
CGRect bounds = [UIScreen mainScreen].bounds;
static inline void rotateScreen(){ if(g_isOGLES2) { switch(g_displayScreen->Angle) { case ROTATION_NONE: case ROTATION_0: g_modelViewMatrix *= Matrix4D::RotateZ(0); break; case ROTATION_90: g_modelViewMatrix *= Matrix4D::RotateZ(90); break; case ROTATION_180: g_modelViewMatrix *= Matrix4D::RotateZ(180); break; case ROTATION_270: g_modelViewMatrix *= Matrix4D::RotateZ(270); break; } } else { switch(g_displayScreen->Angle) { case ROTATION_NONE: case ROTATION_0: glRotatef(0, 0.0f, 0.0f, 1.0f); break; case ROTATION_90: glRotatef(90, 0.0f, 0.0f, 1.0f); break; case ROTATION_180: glRotatef(180, 0.0f, 0.0f, 1.0f); break; case ROTATION_270: glRotatef(270, 0.0f, 0.0f, 1.0f); break; } }}
-(CGRect)boundsForOrientation{ CGSize screenSize = [[UIScreen mainScreen] bounds].size; printf("**** Changed orientation: %d \n", interfaceOrienation); if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { CGRect bounds = CGRectMake(0, 0, screenSize.width, screenSize.height); CGSize size; screenSize = [UIScreen mainScreen].bounds.size; if ((NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) { size=CGSizeMake(screenSize.height, screenSize.width); } bounds = CGRectMake(0, 0, screenSize.height, screenSize.width); return bounds; } else { screenSize = UIInterfaceOrientationIsPortrait(interfaceOrienation) ? CGSizeMake(screenSize.width, screenSize.height) : screenSize; CGRect bounds = CGRectMake(0, 0, screenSize.width, screenSize.height); return bounds; }}
- (void)viewDidAppear:(BOOL)animated{ //UIInterfaceOrientation orientation = [m_viewController interfaceOrientation]; //UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation]; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; [self rotateView:orientation];}