1

I am having an issue my app not loading properly when it initially loads in an orientation other than UIDeviceOrientationPortrait. I support all orientations, and after the initial loading I can properly rotate into any orientation.

It also works to close and reopen the app in any orientation. It only seems to be the initial loading that is causing problems. Any ideas on what might be happening?

I don't even know what code to post to try to demonstrate the issue. Thanks!

Mike Z
  • 4,121
  • 2
  • 31
  • 53

4 Answers4

1

There are two possibilities:

1.) You set up something wrong in your first view. Which I cannot help you without codes.

2.) You are betting your rotation according to your UIWindow. I know this problem well since UIWindow has no method to handle orientation. I think UISplitView does what you mention above but don't hold me on it. Basing on UIWindow messes up with many things like the question above or manual transition between viewControllers. So far, there is no proper fix other than workaround.

In a nutshell, just put a quick check on device orientation (not the statusbar) and rotate the view to the proper orientation in viewWillAppear or something similar. It should not be all that hard since you already have all the rotation code ready.

In case you want to be really lazy, just put [self willAnimateRotationToInterfaceOrientation:[[UIDevice currentDevice] orientation] duration:0.3]]; in your ViewWillAppear. It should, in theory, do the trick.

See also : https://stackoverflow.com/a/3897243/581194 for more ways to get the orientation. If above does not work.

Community
  • 1
  • 1
Byte
  • 2,920
  • 3
  • 33
  • 55
  • I think you hit the nail on the head with 1.). I am using [PSStackViewController](https://github.com/steipete/PSStackedView) and my initial view (if the user isn't logged in) is a modal view to present the login screen. Loading works fine for a logged in user (one who isn't seeing the modal view) but it has the above described issues if they are not logged in or they hit the logout button. – Mike Z Jun 06 '12 at 12:30
  • Ahh there is a missing piece of information "Loading works fine for a logged in user" glad, you solved it. – Byte Jun 07 '12 at 01:10
1

Try this,

On initial loading viewDidLoad will be called, so call your orientation method from viewDidLoad

Code:

[self Methodname:[UIApplication sharedApplication].statusBarOrientation];

Krunal
  • 6,440
  • 21
  • 91
  • 155
1

Try calling this as soon as possible:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
Matic Oblak
  • 16,318
  • 3
  • 24
  • 43
0

It turns out the problem was due to having a "container" view controller and then additional view controllers on the screen that weren't taking up the entire screen. When loading my modal view, I was doing it from one of the smaller view controllers, not the container. Moving the modal view presentation into the container fixed the issue. Thanks for getting me thinking in the right direction.

Mike Z
  • 4,121
  • 2
  • 31
  • 53