views:

52

answers:

3

Hi,

This is a continuation from a previous question that I asked: http://stackoverflow.com/questions/3730190/iphone-view-strategy

I am now using the following method to switch between views:

UIWindow *window = [[UIApplication sharedApplication] keyWindow];
[window setRootViewController:[self gameViewController]];
[[[self gameViewController] view] becomeFirstResponder];

The problem I am having is that none of my views rotate properly (the status bar rotates but nothing else). The initial view is fine but any views that I navigate to using the above method have the problem with rotation.

I have implemented the shouldAutorotateToInterfaceOrientation method in all of my view controllers as follows:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES to allow autorotation
    return YES;
}

This has become a bit of a sticking point for me. Any ideas?

Thanks, Alan

A: 

do you have UITabBarController in there?

GameBit
I am not using UITabBarController. I am just using the view controllers on their own.
Alan Spark
A: 

The shouldAutorotateToInterfaceOrientation method should go in the current view controller for the views, not the UIViews themselves.

hotpaw2
Sorry for the confusion, I was talking about my view controllers not views. I have edited my original post.
Alan Spark
+1  A: 

It might be how you are displaying your views. I was having this problem with a popover that was displaying a modal window. Still not sure what was causing the problem, think it was an apple bug. Why don't you try doing something like this:

[window addSubview:gameViewController.view];
[window makeKeyAndVisible];

This is assuming that your gameViewController is initialized somewhere else in your code. Not sure if that is what you are looking for but it may work.

Geoff Baum