将 iPad XIB 添加到 XCode 4 中基于视图的应用程序模板应用程序
我在 XCode4 中创建了一个基于视图的应用程序;创建应用程序时,我选择 iPhone 作为设备系列:
该应用程序是使用以下文件创建:
我在 TestushViewController.xib 上设计了 UI文件并且不添加任何代码Delegate 文件,应用程序立即上传到 TestushViewController.xib 视图,我对此感到非常高兴。
现在我想添加一个 iPad xib。我该怎么做?
(我知道如何在 XCode 3 中执行此操作,但我在 Delegate 文件中使用了一些代码,现在如果我尝试使用相同的代码,它不起作用,因为模板默认实现的工作方式不同 - Apple 使用 @ class TestushViewController 和 self.window.rootViewController = self.viewController 它直接进入 iPhone.xib 我不知道如何绕过它而不将整个事情更改为是怎么做的在 XCode3)
I've created a View Based Application in XCode4; when creating the application I selected iPhone as the Device Family:
The application was created with the following files:
I designed the UI on the TestushViewController.xib file and without adding any code in the Delegate files, the application is uploading immediately to the TestushViewController.xib view and I'm very happy about it.
Now I want to add an iPad xib. How do I do that?
(I knew how to do it in XCode 3, but I used some code in the Delegate file, and now if I try to use the same code it doesn't work because the template default implementation works differently - Apple uses @class TestushViewController and self.window.rootViewController = self.viewController and it goes directly to the iPhone.xib. I don't know how to go around it without changing the entire thing to the way it was done in XCode3)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要以与窗口模板类似的方式构建代码。创建时勾选“通用”选项时,模板使用的文件结构是:
iPhone 和 iPad AppDelegate 只是 AppNameAppDelegate 的子类
在目标摘要中,您可以设置为每个设备最初加载的 .xib 文件。它被称为“主界面”并有一个下拉菜单。
坦率地说,如果您想做一个通用应用程序(iPhone + iPad),那么从窗口模板开始并添加视图控制器可能更容易,而不是从视图模板开始并尝试更改它。
You'll need to structure your code in a similar way that the Window Template does. The file structure that template uses when the "Universal" option is ticked at creation is:
The iPhone and iPad AppDelegates are simply subclasses of the AppNameAppDelegate
In your target summary you can set what .xib file is initially loaded for each device. It is called the "Main Interface" and has a pulldown menu.
Quite frankly, if you're wanting to do a universal app (iPhone + iPad) it's probably easier just to start with the Window Template and add in your view controllers instead of starting with the View template and trying to change it up.