为什么我的 iPad 应用程序项目无法“启动”?开箱即用的横向模式?

发布于 2024-09-13 12:55:05 字数 616 浏览 2 评论 0原文

这是一个奇怪的问题,因为我确实有过运行良好的项目,可能是因为我一直在做不同的事情。但现在我很困惑。

我使用 Xcode (3.2.3 fwiw) 创建了一个新的基于视图的 iPad 应用程序。这为我提供了一个带有默认视图的默认视图控制器,该默认视图会在启动时取消存档并显示。

当我在模拟器处于横向模式时启动应用程序时,我希望默认视图大小为 1024 宽。但事实并非如此——如果我只向默认项目添加一行:

// 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
}

无论应用程序以纵向模式还是横向模式启动,我都可以看到宽度为 768。开箱即用后,默认视图的自动调整大小蒙版肯定应该重新布局以适合容器。当我以横向模式启动时,为什么这个数字不是 1024?我知道这在我的其他项目中也有效,但我对其中的差异感到困惑。我缺少什么?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

破晓 2024-09-20 12:55:05

viewDidLoad 在视图从 xib 加载后、旋转到初始设备方向之前立即调用。试试这个:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    NSLog(@"rotated to width: %f", self.view.bounds.size.width);
}

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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文