将iPad XIB/VIEW添加到“基于视图的应用程序"中.在iOS 4中 [英] Adding iPad XIB/VIEW to a "View Based Application" in iOS 4

查看:48
本文介绍了将iPad XIB/VIEW添加到“基于视图的应用程序"中.在iOS 4中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 XCode4 中创建了基于视图的应用程序,并尝试按照Apple的预期方式进行代码和UI设计.

I've created a View Based Application in XCode4 and trying to do the code and UI design according to the way Apple have intended it to be.

因此,我在 AppNameViewController.xib 中设计了UI,它可以正常工作;现在,我想启用它作为也在iPad上运行的 UNIVERSAL 应用程序.我将 App-Target >>摘要>>设备 iPhone 更改为 Universal ,神奇地,XCode自动创建了 MainWindow-iPad. xib (苹果,非常好...),但是当我在 AppNameViewController.xib 而不是 MainWindow.xib 上设计应用程序的第一个屏幕时,我在 iPad Simulator 上运行该应用程序,但屏幕却很丑陋,UI对象的大小和位置都失真了(它们的大小仍为iPhone设置,因此它们都粉碎在屏幕的左上角了) ).

So I designed the UI in the AppNameViewController.xib and it works fine; now I want to enable it as a UNIVERSAL application that runs on iPad as well. I changed the App-Target>>Summary>>Devices from iPhone to Universal and miraculously XCode had automatically created MainWindow-iPad.xib (Apple, very nice...), but since I designed the application first screen on the AppNameViewController.xib and not on the MainWindow.xib when I run the app on iPad Simulator I get this ugly screen where my UI objects size and location is distorted (their size is still set for iPhone so they are all crumbled on the left-top corner of the screen).

在我以前的应用程序中,我使用下面显示的代码来区分 AppNameViewControllerForIPHONE.xib AppNameViewControllerForIPAD.xib ;它是通过 AppDelegate.m 文件完成的,但是在新的XCode 基于视图的应用程序模板中,AppDelegate不会通过 initWithNibName 方法进行操作全部.

In my previous app I used the code appearing below to distinct between the AppNameViewControllerForIPHONE.xib and the AppNameViewControllerForIPAD.xib; It was done from the AppDelegate.m file, but in the new XCode View Based Application template the AppDelegate doesn't go through initWithNibName method at all.

我在XCode 3上使用的代码无法在XCode 4上使用:

Code I used on XCode 3 that cannot be used on XCode 4:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

viewController = [[AppViewController alloc] initWithNibName:@"AppViewControllerIPAD" bundle:[NSBundle mainBundle]];

}

else {

viewController = [[AppViewController alloc] initWithNibName:@"AppViewControllerIPHONE" bundle:[NSBundle mainBundle]];

}


长的问题...还是,任何人都不知道应该如何在这里完成?我应该在哪里设计iPad UI,或者有什么方法可以轻松地将iPhone xib转换为iPad?


Long question... still, anyone had any idea how it should be done here? Where should I design the iPad UI or is there a way to easily transform the iPhone xib to an iPad one?

推荐答案

您必须遵循为

You have to follow the new naming scheme (idiom in Apple-speak) specified for Universal Applications for the NSMainNibFile key in your info.plist. For example, if you set your NSMainNibFile to be "MainWindow-iPhone", the xib for ipad would be "MainWindow-iPad".

基于视图的应用程序中的视图应具有相同的命名约定(我现在无法测试,安装新的xcode).

The same naming convention should hold for the views in a view based application (I can't test right now, installing new xcode).

这篇关于将iPad XIB/VIEW添加到“基于视图的应用程序"中.在iOS 4中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆