views:

129

answers:

2

I have a view controller which manages a view.

I'm adding the my view controller subclass as a subview of the window swapping out another view.

I'm running landscape mode on an iPad.

The view apparently doesn't know that its in landscape mode. Its frame is confused.

Is there something I can/should do to tell it that its in landscape, and/or that the orientation has changed. How does this normally happen. Why isn't it happening?

I used to have my view controller within a UITabBarController and it worked fine there.

A: 

Override:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return YES;
}
Sheehan Alam
Thats already in there. That isn't the problem.
David
A: 

Your ViewController is not getting rotation events because you have not presented the viewController but have added the viewController's view in the view hierarchy.

Your Tab bar controller previously used to take the responsibility to forward the rotation events to the view controller which it manages, that was how it used to work.

I would though suggest that swapping the view out of window is a bad idea. Instead you should have a main viewController which accepts the rotation events and then swap the view within this viewController based on the current orientation. Consider re-desiging before you code further.

Raj
Are you suggesting having my own root view controller and swap subviews? One of the views is a UISplitView and it didn't seem to like this. But maybe again I'm not telling it enough or forwarding enough events. Is there an example of the best way to switch views?
David
If you are using a splitViewController, I am afraid, split view controller should be a main view controller always. Rotation events need not be passed explicitly. The messages are and should be sent internally. Swapping views after rotation is not pleasing to eyes. The UI switches suddenly when the rotation occurs. When rotation occurs, the views should be RESIZED with proper autoresizing masks set. But though, if you have such requirement, you can go ahead with my suggestion + provided that you wont have split view as subview, since it doest get rotation events.
Raj