开发者

iPhone view won't rotate

This is a continuation from a previous question that I asked: 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 control开发者_StackOverflow社区lers 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


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.


do you have UITabBarController in there?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜