开发者

Why won't my iPad app project "start" in landscape mode out of the box?

开发者 https://www.devze.com 2023-01-10 21:49 出处:网络
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.

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 vi开发者_JS百科ew 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!


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);
}
0

精彩评论

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