6

since iOS 8 my App runs quite good, but I found a Problem while testing this app. It just happens on iPad and only if I launch the app in landscape mode. If it launches in Portrait everything is right(no rotation issues). If i rotate the Device (simulator or real device) the view rotates out of the screen and just shows a Cut of the real view and the rest is black.

enter image description here

enter image description here

Anyone else did notice such a bug? How can I fix it?

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
Tristan G
  • 1,720
  • 2
  • 13
  • 22
  • 1
    Without seeing the images, my initial reaction based on what you describe is that you perhaps have an issue with your auto layout constraints. Does the issue go away when you rotate then go back to landscape? – squarefrog Oct 23 '14 at 08:25
  • If I rotate it back to how I launched it in landscape, the view is shown right, but if I rotate it bugs like discribed. But that just happens if I start the App in landscape. – Tristan G Oct 23 '14 at 08:34
  • Can you provide a link to your screen shot on a third party site like [imgur](http://imgur.com)? What auto-layout constraints do you have set up? – squarefrog Oct 23 '14 at 08:36
  • it’s a bug with shouldAutorotate in iOS8 - it is not called when switching to Portrait (or ... will be deprecated) http://stackoverflow.com/questions/26503423/shouldautorotate-behavior-in-ios-8 – TonyMkenu Oct 23 '14 at 08:39
  • in iOS8 you can use: viewWillTransitionToSize (if you are using AutoLayout) – TonyMkenu Oct 23 '14 at 08:43
  • viewWillTransitionToSize hasn´t worked for me, or maybe I am just too stupid to use it the right way – Tristan G Oct 23 '14 at 12:13

4 Answers4

5

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

Commented initialising of self.window and its assignment. Set the initial view in storyboard in Attributes inspector by checking "Is Initial View Controller" checkbox.

New Better Solution
Commenting self.window was causing other issues. Instead the below code is best:

- (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification 
    {
         [UIViewController attemptRotationToDeviceOrientation];
    }
Mitech
  • 400
  • 4
  • 6
  • This doesn't seem to fix it for me, but I'm having the same exact issue. I have an app that's all portrait except for one view controller which puts it in landscape. If I rotate the view gets all funky. This is on any size iphone with iOS 8. – CodyMace Mar 25 '15 at 22:16
  • @CodyMace I'm having the same exact issue. Did you fix it? – doxsi Dec 18 '15 at 12:50
2
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight);
NSLog(@"Currently landscape: %@, width: %.2f, height: %.2f", 
      (landscape ? @"Yes" : @"No"), 
      [[UIScreen mainScreen] bounds].size.width, 
      [[UIScreen mainScreen] bounds].size.height);

And the results are: For iOS 8+

Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 568.00, height: 320.00

and for iOS 7-

Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 320.00, height: 568.00

It seems like there is a change in the way height and width of the screen is handled while in portrait and landscape from ios8 onwards.

Check this link Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?

Community
  • 1
  • 1
Rinto Rapheal
  • 142
  • 1
  • 10
2

UPDATE - We found a fix:

I found the answer to our problem which as described below appeared to be exactly the same as yours. One of our other developers noticed an "unexpected nil in main window" when attempting to tap on the far right of the screen. This led me to do a new search and I found this thread on stackoverflow that actually contained the answer to our problem.

( here is the link to the question which help my answer: unexpected nil window in _UIApplicationHandleEventFromQueueEvent )

The actual answer came from frankish who suggested opening the main.xib (or main storyboard) and clicking on the Window in that and making sure that the "Visible at Launch" and "Full screen at Launch" properties are checked (set to true.)

In our case, it was JUST the "Full screen at Launch" property that needed to be set, but setting this fixed the rotation problem we were seeing AND it fixed an issue where when launching on iPad in landscape the far right of the screen was not touchable.

END UPDATE - (original non-answer below)

My answer isn't an answer, but I have run into the exact same issue. On rotate in our app, when building with Xcode 6, I see the exact same rendering issue as the the screenshots on this question. The exact same out of position rotate with black bars at the side and bottom. (Our app on iPhone doesn't support any rotation so we don't see the issue on iPhone. On iPad we support landscape left and landscape right. When rotating from one to the other, when the iPad does it's standard rotation animation, it will rotate out of position (showing the black bars) when going one way and then rotate back into proper position when going back to the other supported orientation. I don't believe it's related to any custom positioning or animation code. It happens with every screen, including the splash screen. It appears to be related to the built in Apple screen rotation. Obviously not every project has this issue in iOS but I have not come across the particulars that are causing this issue. I spent all day yesterday researching the issue and going through our code and I have nothing.

One piece of additional info. If I build with Xcode 6 and run on a device with iOS 7 then there is not issue. This issue ONLY happens when I build with Xcode 6 and run on a device with iOS 8.

Here is a link to my own question posted yesterday about this issue. (I did not come across this question until after I'd posted my question.)

Building project with Xcode 6 (iOS 8 SDK) causes landscape rotation rendering issue on iPad

Community
  • 1
  • 1
Marc
  • 31
  • 3
0

I found this to be an issue when I had multiple windows in my application. By setting a breakpoint on -[UIWindow setFrame:], I was able to see that upon rotation, the system was giving me giving me an erroneous frame size and position. You can get around this by manually setting your frame to equal [UIScreen mainScreen] bounds] which seems to be correct if you running on iOS7+ and compiling with Xcode6. I found that doing this in -[UIWindow becomeKeyWindow] worked well for me:

- (void)becomeKeyWindow {
    [super becomeKeyWindow];

    self.frame = [UIScreen mainScreen].bounds;
}
ohnit
  • 423
  • 3
  • 9