在XCode 4中将iPad XIB添加到基于视图的应用程序模板应用程序 [英] Adding iPad XIB to a View Based Application Template Application in XCode 4

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

问题描述

我已经在 XCode4 中创建了基于视图的应用程序;在创建应用程序时,我选择了iPhone作为设备系列:

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:

我在 TestushViewController.xib 文件上设计了UI,并且没有在 Delegate 文件中添加任何代码,该应用程序立即上载到 TestushViewController.xib 视图,对此我感到非常高兴.

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.

现在,我想添加一个 iPad xib .我该怎么办?

Now I want to add an iPad xib. How do I do that?

(我知道如何在XCode 3中做到这一点,但是我在Delegate文件中使用了一些代码,现在,如果我尝试使用相同的代码,它将无法正常工作,因为模板默认实现的工作方式有所不同-Apple使用 @class TestushViewController 和s elf.window.rootViewController = self.viewController ,它直接进入iPhone.xib.整个过程都在XCode3中完成)

(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)

推荐答案

您将需要以与Window模板类似的方式来构造代码.在创建时选中通用"选项时,模板使用的文件结构是:

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:

App Name/
  AppNameAppDelegate
  iPhone/
    AppNameAppDelegate_iPhone
    MainWindow_iPhone.xib
  iPad/
    AppNameAppDelegate_iPad
    MainWindow_iPad.xib

iPhone和iPad AppDelegates只是AppNameAppDelegate的子类

The iPhone and iPad AppDelegates are simply subclasses of the AppNameAppDelegate

@interface YourAppNameAppDelegate_iPhone : YourAppNameAppDelegate {}

在目标摘要中,您可以设置最初为每个设备加载的.xib文件.它被称为主界面",并具有一个下拉菜单.

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.

坦率地说,如果您想做一个通用应用程序(iPhone + iPad),从窗口模板"开始并添加视图控制器,而不是从视图模板"开始尝试进行更改,可能会更容易.

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.

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

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