0

I've created a simple single view application which is intended to resize/rearrange its layout when the device is rotated to a new orientation. I'm using size classes and AutoLayout.

The layout changes properly in the xcode simulator (ios8 on all tested devices), but when I try to run it on my phone the view appears properly in portrait but does not rotate to landscape.

The status bar(time, signal battery) rotates off the screen but the view does not move at all. What could be causing this? The device is an iphone 5, ios 8.1

I'm happy to post any code you want to see, please let me know what's relevant.

Thank you!

Edit: Ok so I just upgraded xcode to 6.1 from 6.01 and the problem now exists in the simlator and the device so it must be something I've setup wrong in code.

Here is how the app looks in the interface builder preview storyboard preview.

Here is the app in portrait. portrait

And Landscape. landscape

As you can see the statusbar rotates but the apps main view does not. My main view is a child view of the banner view to display the iad as demonstrated here in the container banner demonstration.

TPB
  • 737
  • 1
  • 6
  • 8
  • HI can you please add the screen shot from simulator and device both. If possible also how you have set the constraints. – Dhaivat Vyas Jan 02 '15 at 02:47
  • @iOS_DK thanks for the reply, I added some screen shots to show the issue. I think I must not be handling rotation correctly because my main view is a child vc of an ad banner delegate. I can post my init and rotation handling code too if needed. – TPB Jan 02 '15 at 17:33

1 Answers1

0

OK so I figured this out thanks to this answer:iOS 8.1 auto rotation

For some reason (which I would love to know why if anyone has an answer) removing this line

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

from the app delegate applicationDidFinishLaunching method corrects the issue...weird.

Community
  • 1
  • 1
TPB
  • 737
  • 1
  • 6
  • 8
  • You normally don't need to create a window unless you have a specific need to do so. If you don't know that you have that need, you don't have that need. This post seems to have a high-level overview of some of the pitfalls and/or purposes of creating an additional UIWindow. http://shaune.com.au/using-multiple-uiwindows-in-ios-applications/ – Brad Brighton Jan 02 '15 at 18:19
  • @BradBrighton thanks thats good to know. I was actually just following apples guide [here](https://developer.apple.com/library/ios/samplecode/iAdSuite/Listings/ContainerBanner_ContainerBanner_BannerViewController_m.html#//apple_ref/doc/uid/DTS40010198-ContainerBanner_ContainerBanner_BannerViewController_m-DontLinkElementID_11) I had thought it should have worked because I did it exactly the same way apple did it in that example project, but I guess that way is no longer compatible with recent iOS updates. – TPB Jan 02 '15 at 20:05
  • Turns out I'm doing too many things at once and giving partially bad advice. The "if you wind up getting multiple windows" thing is correct, but as I was researching your comment, I realize that I have that same window creation code in my own -- it's template code and I've seen it so often it's invisible to me. Did you by chance have two UIWindow creates in your didFinishLaunching? (I'm bowing out beyond this though to keep from making myself look more foolish...) – Brad Brighton Jan 02 '15 at 20:18
  • @BradBrighton: No, I did not create two windows but I do have: `self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];` in the banner view controller. My appdelegate and banner container are exactly as it is in the apple iAd demo project. I took that project and just added my code to the ViewController class. This is one reason I was so confused it didnt work, but that project is written for ios6 so I'm guessing its an issue with ios8 – TPB Jan 02 '15 at 20:31