views:

155

answers:

1

This is a weird question inasmuch as I've definitely had projects that work fine, possibly because I've been doing something differently. But now I'm confounded.

I create a new View-based iPad app with Xcode (3.2.3 fwiw). This gets me a default view controller with a default view which gets unarchived and displayed at startup.

When I start the app while the simulator is in landscape mode, I expect that default view to size to be 1024 wide. But it's not-- If I add just one line to the default project:

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"width: %f", [[self view] bounds].size.width); // add this line
}

I can see that the width is 768, whether the app starts in portrait or landscape mode. Out of the box, the autoresize mask of that default view should definitely relayout to fit the container. Why isn't this number 1024 when I start in landscape mode? I know this works in other projects I have but I'm confounded by what the difference is. What am I missing?

Thanks!

+1  A: 

viewDidLoad is called immediately after the view loads from the xib, before it's rotated to the initial device orientation. Try this:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    NSLog(@"rotated to width: %f", self.view.bounds.size.width);
}
jtbandes
Oy. Thanks. I was distracted by a red herring in my debugging and ended up going back to basics by creating this dummy project only to find myself going nuts. Thanks for the steering.
quixoto