1

I have an app, haven't modified it since 6 months ago, anyway I decided to open it up in the simulator. But the first viewcontroller which shows after the splash screen is scrunched up and is showing through the wrong orientation. It's showing in portrait when it should be showing in landscape.

This is the code for it:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

However,

When I tap to go to another view, then go back to the main viewcontroller, the problem fixes itself and the orientation is correct.

showing correctly

So it only happens on the initial launch after the splash screen is shown.

Please join the links together to view the screenshots as i cannot post images as i haven't got 10 reps yet.

Mohsen Safari
  • 6,669
  • 5
  • 42
  • 58
John Kee
  • 45
  • 1
  • 3
  • 10
  • Is your project giving you warning that "Project should have RootViewController"? or anything something similar? – Rushi Feb 28 '13 at 12:07
  • If You are using xcode 4.6 or ios 6.0 o above then ur above said method is being deprecated and u have to add a new set of mthods for the autorotation support. – vishwa.deepak Feb 28 '13 at 12:08
  • And @vishwa.deepak whats the new method for autorotation for iOS 6? – John Kee Feb 28 '13 at 12:16
  • you can have a lot of alternative accepted answers here: http://stackoverflow.com/questions/12260261/shouldautorotatetointerfaceorientation-not-being-called-in-ios-6 and also can accept my comment :) – vishwa.deepak Feb 28 '13 at 12:21

2 Answers2

0

enter image description here This will make sure the app to open in landscape mode .

In the AppDelegate you may be using this

[self.window addSubView:viewControllerObj]

The problem was with the above line. Orientation will work properly with the above line in iOS 5 but in iOS 6, for orientation to work properly, change the above line with

[self.window setRootViewController:viewControllerObj]

Then the app rotates when orientation changes

Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
  • Tried this, but the image still sets to portrait but the device is landscape. Edit: tried with the code but still the same. – John Kee Feb 28 '13 at 12:24
  • are you sure you add this code to your disoriented viewcontroller? – Lithu T.V Feb 28 '13 at 12:26
  • @Lithu T.V Are u sure about calling this method in viewcontroller, u can self check this method is not called for iOS-6 by using breakpoints. – vishwa.deepak Feb 28 '13 at 12:26
  • Yeah the code is placed in the viewcontroller where this is occurring – John Kee Feb 28 '13 at 12:28
  • @JohnKee: Thers no short cut for this u have to add category for UINavigationcontroller or UITabbarcontroller depending on ur requirement for autorotation detection and support. – vishwa.deepak Feb 28 '13 at 12:28
  • http://stackoverflow.com/questions/12260261/shouldautorotatetointerfaceorientation-not-being-called-in-ios-6 chk this – Lithu T.V Feb 28 '13 at 12:30
  • Hey sorry for the late reply, you fixed it. Thanks so much, was stressing so much. – John Kee Mar 01 '13 at 14:42
0

Open your plist file ->addRow-> add "Initial interface orientation" and give value Landscape (left home button).

Hope this will help you.

Ashim
  • 276
  • 1
  • 5