4

I'm using Xcode 4.3.2 and an iPad simulator 5.1

I really need some help with this, my app is stuck at portrait mode.

When I rotate the simulator I've tried looking under the project settings and have these checked: Portrait, Upside Down, Landscape Left and Landscape Right.

I also these methods in the view controllers:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

can anyone please help?

Till
  • 27,559
  • 13
  • 88
  • 122
  • When you port to IOS 6 you will need additional code: http://stackoverflow.com/questions/12565693/xcode-4-5-ios-6-0-simulator-orientation-not-working/12568678#12568678 – gjpc Sep 24 '12 at 17:52

4 Answers4

3

Check your supporting orientations in the project's settings or on *.plist file. Also, if you are using UITabBarController or smth else, all of your controllers have to support all orientations!

demon9733
  • 1,054
  • 3
  • 13
  • 35
  • I already made sure in the project settings and the plist that all orientations are enabled. This is a simple Single View Application "Hello World" app. What do you mean by that? Sorry I'm a beginner trying to learn Xcode.. – learningKoding Apr 27 '12 at 12:56
  • Press '+' button at the left of the orientation name and chose the one of the list. And again until you have all 4 orientations. Doesn't matter, what king of app it is. – demon9733 Apr 27 '12 at 13:00
  • OK. Again, you have only `AppDelegate` and `ViewController` classes, no more? In the project's settings all orientations are enabled and in `ViewController` class you have `shouldAutorotateToInterfaceOrientation:` method, that returns `YES`? If all of it is true, I don't know, what may cause a problem. Can you check your app on device? – demon9733 Apr 27 '12 at 13:04
  • Thank you for helping me. I looked at the settings and the method and they exists. Yes, I only have AppDelegate.h, AppDelegate.m, ViewController.h and ViewController.m. On the MainStoryboard.storyboard there are 2 view controllers and an Navigation Controller and a button. I dont have a developers account yet, so I can't test it. The app is still only to support portrait orientation. Heres the project:http://www.mediafire.com/download.php?898z24aauv2e064 Maybe I'm missing something obvious here? – learningKoding Apr 27 '12 at 13:20
  • Honestly, I've never used storyboard :) So wait, I'll try to figure it out. – demon9733 Apr 27 '12 at 13:28
  • Thank you for your effort I appreaciate it :-) Hope it doesn't tak to loong, hehe. – learningKoding Apr 27 '12 at 13:33
  • Well, I really don't know what's wrong. I'd recommend you to create the new project without storyboard. So, if you'll have any questions, I would try to help :) – demon9733 Apr 27 '12 at 13:40
  • Here's what's wrong with your sample project. If you go to the View controller, and go to the identity inspector, the class name is set to LKViewController. I don't know what that is but if you want it to point to your customer view controller `ViewController`, you need to change the name appropriately: ViewController in the Class field. I did that and since you properly overrode the `- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation` it all works. – mprivat Apr 28 '12 at 13:28
1

use cmd+shift+f and type - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

make sure all of them return YES if you want all orientations supported and NO For unsupported orientations

Jason McTaggart
  • 878
  • 1
  • 7
  • 18
  • Thanks, the only file that had that was ViewController.m, and it was already set to return YES. Still having this problem.. heres the project: http://mediafire.com/download.php?898z24aauv2e064 (a simple "hello world" view controller) – learningKoding Apr 27 '12 at 13:31
1

Make sure you only have one controller showing. I've seen this problem when I have multiple views with different controllers showing at the same time.

mprivat
  • 21,582
  • 4
  • 54
  • 64
  • It's a single view controller app? – learningKoding Apr 27 '12 at 13:36
  • Does the status bar rotate? In a single view app, you can have multiple subviews. if they have their own controllers, you will have this problem. The status bar rotates but not the root controller. – mprivat Apr 27 '12 at 13:40
  • The iOS bar is always the opposite to the home button on the simulator. I think this is the problem? but I don't know where to start fixing it, can you please help? btw, heres the screenshot of the storyboard: http://imgur.com/Wuhfn – learningKoding Apr 27 '12 at 14:05
  • Anybody with a solution? I'm still having trouble autorotating this hello world app.. Please? – learningKoding Apr 28 '12 at 12:40
1

Yeah I had the same problem and the other answers here didn't fix my situation. I found I had to check the "Resize View from NIB" box in all the relevant views.

See screenshot below (although shows a slightly older version of XCode).

Community
  • 1
  • 1
Simon East
  • 55,742
  • 17
  • 139
  • 133