为什么我的 iPad 应用程序项目无法“启动”?开箱即用的横向模式?
这是一个奇怪的问题,因为我确实有过运行良好的项目,可能是因为我一直在做不同的事情。但现在我很困惑。
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
viewDidLoad
在视图从 xib 加载后、旋转到初始设备方向之前立即调用。试试这个:viewDidLoad
is called immediately after the view loads from the xib, before it's rotated to the initial device orientation. Try this: