将iPhone应用程序转换为通用应用程序?

问题描述:

我有一个iPhone应用程序
FirstViewController SecondViewController 各自的观点 FirstView.xib SecondView.xib

I have an iPhone app with FirstViewController and SecondViewController with respective views FirstView.xib and SecondView.xib.

现在我想让这个应用程序适用于iPhone和iPad。对于iPad,我需要合并 Firstview.xib SecondView.xib 进入单个 ThirdView-iPad.xib

Now I want to make this app work with both iPhone and iPad. For iPad I need to merge Firstview.xib and SecondView.xib into a single ThirdView-iPad.xib.

什么是最好的方法?我是否需要为iPad编写另一个ViewController类,或者我可以使用现有的 FirstViewController SecondViewController $单个xib的c $ c>

What would be the best approach? Do I need to write another ViewController class for iPad or can I use existing FirstViewController and SecondViewController with single xib?

到目前为止,我的研究表明,没有办法将多个ViewControllers与单个xib一起使用。请告诉我最好的方法。

My research so far says that there is no way to use multiple ViewControllers with single xib. Please let me know the best way to do this.

谢谢

除非你是受虐狂,否则你最好只创建一个新的ViewController。以这种方式重用很可能会遇到很多麻烦,如果你需要在ViewControllers中重用逻辑,我会选择聚合或继承。

You would be best of to just create a new ViewController unless you're into masochism. Reusing in that way would most likely be to much trouble, and I'd go with aggregation or inheritance in the case you need to reuse logic in your ViewControllers.

我通常创建一个基本的ViewController,比如 XYZViewController 然后用所有iPhone特价和一个单独的 XYZViewController_iPhone c>适用于iPad的XYZViewController_iPad 。但如果它们完全不同,我会给它们提供唯一的名称和它们自己的NIB以及ViewControllers。

I typically create a base ViewController, say XYZViewController and then create a XYZViewController_iPhone with all iPhone-specials and a separate XYZViewController_iPad for iPads. But if they're totally different I give them unique names and their own NIBs as well as ViewControllers.