Rotation issue with ios 8 for viewing which are added to windows

enter image description here I created a category to view rotation, and also added views to view controllers, as well as a window (to display a custom indicator). My code works fine up to 7.X with xCode 5.X as well as xCode6-beta6. But not suitable for iOS 8 beta testing. Window rotation does not seem to work with ios 8 beta, like old ios.

Could you suggest me .... Thanks in advance.

My code looks like

- (void)application:(UIApplication *)application willChangeStatusBarOrientation:(UIInterfaceOrientation)newStatusBarOrientation duration:(NSTimeInterval)duration { if(!self.isIpad) { [menu.view rotateViewToOrientation:newStatusBarOrientation animated:YES]; if(newStatusBarOrientation==UIInterfaceOrientationPortrait || newStatusBarOrientation==UIInterfaceOrientationPortraitUpsideDown) { if (IS_IPHONE_5) { menu.view.frame= CGRectMake(0, 518, 320, 50); } else { menu.view.frame= CGRectMake(0, 430, 320, 50); } } else if(newStatusBarOrientation==UIInterfaceOrientationLandscapeLeft) { if (IS_IPHONE_5) { menu.view.frame= CGRectMake(270,0,50,568); } else { menu.view.frame= CGRectMake(270,0,50,480); } } else { if (IS_IPHONE_5) { menu.view.frame= CGRectMake(0,0,50,568); } else { menu.view.frame= CGRectMake(0,0,50,480); } } [menu reloadMenu]; } } //Method of Menu Class for orientation change setup - (void)rotateViewToOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated { CGPoint center = self.center; CGRect bounds = self.bounds; CGAffineTransform transform = CGAffineTransformIdentity; int intOri=orientation; switch (intOri) { case UIInterfaceOrientationPortraitUpsideDown: transform = CGAffineTransformMakeRotation(M_PI); break; case UIInterfaceOrientationLandscapeLeft: transform = CGAffineTransformMakeRotation(-M_PI_2); break; case UIInterfaceOrientationLandscapeRight: transform = CGAffineTransformMakeRotation(M_PI_2); break; case UIInterfaceOrientationPortrait: transform = CGAffineTransformMakeRotation(0); break; } if (animated) { [UIView beginAnimations:nil context:nil]; } self.transform = transform; bounds = CGRectApplyAffineTransform(bounds, transform); self.bounds = CGRectMake(0, 0, bounds.size.width, bounds.size.height); self.center = center; if (animated) { [UIView commitAnimations]; } } 
+6
ios objective-c ios8
Sep 05 '14 at 11:29
source share
3 answers

I tried many fixes ... and its working with a patch like

 { [self.window setBounds:temp]; [menu.view setFrame:CGRectMake(0, self.window.frame.size.height-50, self.window.frame.size.width, 50)]; [menu.view removeFromSuperview]; [self.window addSubview:menu.view]; [self.window makeKeyAndVisible]; } 

and reselling angle up to 0 degrees for CGAffineTransformMakeRotation for all kinds of device mode. for ios 8.

This is not the right solution that I know, but I have no alternative way to wait for a good answer.

+7
06 Sep '14 at 10:00
source share

In my case, just setting the rotation angle to 0 for all orientations, fixed the problem. Prior to iOS 8, UIWindow coordinates were always in portrait orientation, so you had to handle the rotation yourself. This is no longer needed in iOS 8. As for why you are adding UIViews to UIWindow, I am doing this for warnings that I want to display on top of everything else, regardless of the current view hierarchy.

+4
Sep 29 '14 at 23:02
source share

There was a similar problem. Surprisingly, the fix was to comment out all the code related to self.window on Appdelegate.

Commented on the initialization of self.window and its purpose. Set the initial view in the storyboard in the attribute inspector by checking the box "Is the initial view controller."

New best solution
Commenting on self.window caused other problems. Instead, the best code is:

 - (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification { [UIViewController attemptRotationToDeviceOrientation]; } 
+1
Jan 05 '15 at 7:12
source share



All Articles