[Question updated]
So here is the problem, I finally narrowed it down to this. If you create a new UIViewController in all methods
- (id)init;
- (void)loadView;
- (void)viewDidAppear:(BOOL)animated;
- (void)viewDidLoad;
(...)
The standard interfaceOrientation is Portrait and if landscape mode is detected it will quickly rotate to that orientation. Which can then be detected using the:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
The problem is that on the iPad, it's quiet difficult to prepare your interface for the current interface orientation within the loadView (or one of the others) as it will only return Portrait. This will cause for a few problems:
1) I want my content to reload in portait mode, but NOT in landscape mode. Normally I would place an if statement in the loadView. If in portrait mode, reload content. But in this case it will always return portrait and thus always loads content.
2) I want to use 'presentPopoverFromRect:inView:permittedArrowDirections:animated:'-method when in portrait mode so it will present the popover menu automaticly when the application starts. This will crash the application when launched in portrait mode. Reason: 'Popovers cannot be presented from a view which does not have a window.'.
The only safe assumption is within 'didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation', but this method will not be fired if it launches in portrait mode.
//----
Update (15.37)
'UIApplicationWillChangeStatusBarOrientationNotification'
Will only be posted when the user swaps from portrait to landscape (or vica versa). If interface was the problem then this can easily be solved with observing for that notification and
if (UIDeviceOrientationIsPortrait(interfaceOrientation)) {
// layout subviews for portrait mode
} else {
// layout subviews for landscape mode
}
But the problem is that I want to know in which mode it is at launch to determine rather or not I should reload the content, I can't reload the content and when it swaps to landscape cancel it.
UIDeviceOrientationIsPortrait()inlayoutSubviewsof a customUIViewsubclass and I'm getting the correct orientations. Do you have some more code that you could share that might help identify what the issue is? Also wondering if UIDeviceOrientation and UIInterfaceOrientation values might be getting used interchangeably? That has gotten me stuck with weird bugs before. - justinkmunger