简体   繁体   English

iOS-将iP​​hone Build转换为iPad

[英]iOS - Converting iPhone Build to iPad

I have a application that I built that was to be build as an iPhone-only application. 我有一个构建的应用程序,该应用程序将被构建为仅限iPhone的应用程序。

Now, I am told that the application has to be made universal now. 现在,我被告知该应用程序现在必须通用。 I will have to make it iPad compatible too (in portrait-only mode). 我也必须使其与iPad兼容(仅纵向模式)。 I have been looking for my options right now as the XIBs in this project are heavily loaded with objects so programatically assigning co-ordinates will be a pain. 我一直在寻找我的选择,因为该项目中的XIB负载了很多对象,因此以编程方式分配坐标会很麻烦。

I am looking for the best, and the quickest approach I should take to make this iPhone app into iPad-compatible app as well. 我正在寻找使该iPhone应用程序也成为兼容iPad的应用程序的最佳方法。

PS: There is no mainwindow.xib file as the application was built with XCode 4.3 which doesn't create the MainWindow.xib file. PS:没有mainwindow.xib文件,因为该应用程序是使用XCode 4.3构建的,该代码不会创建MainWindow.xib文件。

Thank you in advance. 先感谢您。

EDIT: I have made duplicate XIBs for iPad for all the XIBs. 编辑:我为所有XIB制作了用于iPad的重复XIB。 Now, I am trying to use the naming convention which tells me to change the filename suffix to MyiPadXIB~ipad.xib and when the app is run on iPad, it will automatically take that XIB. 现在,我尝试使用命名约定,该约定告诉我将文件名后缀更改为MyiPadXIB〜ipad.xib,并且在iPad上运行该应用程序时,它将自动使用该XIB。 This doesn't seem to be happening. 这似乎没有发生。

When I open the application in iPad, only a small window appears (the window that appears when iPhone-only app is run on an iPad). 当我在iPad中打开应用程序时,仅会出现一个小窗口(当在iPhone上运行仅iPhone的应用程序时出现的窗口)。

Any solution to this? 有什么解决办法吗?

I followed a very easy approach where I would just create duplicate XIBs of all the XIBs by doing Build settings > target (iPhone)> right click and choose duplicate. 我采用了一种非常简单的方法,即通过执行“构建设置”>“目标(iPhone)”>右键单击并选择重复项,来创建所有XIB的重复项XIB。

I would then change the name of the duplicate xibs in this format: "iPhone XIB name"~ipad.xib. 然后,我将使用以下格式更改重复的xib的名称:“ iPhone XIB名称”〜ipad.xib。

The system would then automatically pick up the XIB according to the device used. 然后,系统将根据使用的设备自动拾取XIB。

From what I know (there may be a quicker/better approach that i dont know of) 据我所知(可能是我不知道的一种更快/更好的方法)

You would create seperate xib files for the ipad 您将为ipad创建单独的xib文件

when you init your view controller you check to see what device you are on like so 当您初始化视图控制器时,您会检查以查看您正在使用的设备,如下所示

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        self.serverSettingsViewController = [[ServerSettingsViewController alloc] initWithNibName:@"ServerSettingsViewController_iPhone" bundle:nil];
        self.motionJpegViewController = [[MotionJpegViewController alloc] initWithNibName:@"MotionJpegViewController_iPhone" bundle:nil];
    } else {
        self.serverSettingsViewController = [[ServerSettingsViewController alloc] initWithNibName:@"ServerSettingsViewController_iPad" bundle:nil];
        self.motionJpegViewController = [[MotionJpegViewController alloc] initWithNibName:@"MotionJpegViewController_iPad" bundle:nil];
    }

And load you iphone or ipad xib file (FYI make sure the xib views are large enough for the ipad) 并加载您的iphone或ipad xib文件(仅供参考,请确保xib视图足以容纳ipad)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM