简体   繁体   English

iOS:应用通用概念

[英]IOS: app universal concepts

I'm starting a project that must be for iPhone and iPad...you can tell me that it's easy and that I can create an "Universal" project..it's right. 我正在启动一个必须用于iPhone和iPad的项目...您可以告诉我,这很容易,而且我可以创建一个“通用”项目。 But I have a "stupid" question about a "stupid" problem. 但是我有一个关于“愚蠢”问题的“愚蠢”问题。 In an universal project I have two .xib (iPhone and iPad) for a class and inside code I verify if I'm using the one or the other 在一个通用项目中,一个类有两个.xib(iPhone和iPad),并且内部代码验证我是否正在使用一个或另一个

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
     // The device is an iPad running iPhone 3.2 or later.
}
else
{
     // The device is an iPhone or iPod touch.
}

ok? 好?

But you know that in a single view of iPad I can show many views that an iPhone can show one at time. 但是您知道,在iPad的单个视图中,我可以显示iPhone可以一次显示的许多视图。 At example I have two view with their classes: 例如,我对他们的班级有两种看法:

FirstView.h-FirstView.m-FirstView_iPad.xib-FirstView_iPhone.xib

and

SecondView.h-SecondView.m-SecondView_iPad.xib-SecondView_iPhone.xib

For iPhone it's not a problem but for iPad? 对于iPhone,这不是问题,但是对于iPad? In a view in iPad I can put first and second viewcontroller, it's not easy to organize if I have two different classes for two viewcontrollers... Do you have a solution for this? 在iPad上的视图中,我可以放置第一个和第二个ViewController,如果我为两个ViewController设置了两个不同的类,那么组织起来就不容易...您对此有解决方案吗? Or the best solution is crate two separate project iPhone and iPad? 还是最好的解决方案是建立两个独立的项目iPhone和iPad? thanks 谢谢

So yeah I always use one theViewController.h and one theViewController.m and I have a theViewController.xib for iPhone and a separate xib for iPad only. 所以,是的,我总是使用一个theViewController.h和一个theViewController.m,并且我有一个用于iPhone的theViewController.xib和一个单独的用于iPad的xib。 if you name the iPad xib ending with theViewController~ipad.xib the OS will automatically recognise the XIB. 如果将iPad xib命名为ViewController〜ipad.xib结尾,则操作系统将自动识别XIB。 You will have to set the class of the theViewController~ipad.xib in Interface builder in the inspector area to the same class as your iphone xib ie the class would be called theViewController then you can connect up what ever outlets you have defined in your .h and .m also the great thing about just naming the iPad xib to ending with ~ipad.xib when you push views you dont have to check the idom before pushing as the OS recognises the ~ipad.xib extension and pushes the correct view depending on device..hopefully this is helpful for you! 您必须在“检查器”区域的“接口”构建器中将theViewController〜ipad.xib的类设置为与iphone xib相同的类,即该类称为theViewController,然后您可以连接在中定义的插座。 h和.m也是一件很棒的事情,当您按视图时,仅将iPad xib命名为〜ipad.xib结尾,因为操作系统可以识别〜ipad.xib扩展名并按正确的视图进行推送,所以不必在推送之前检查idom在设备上..希望对您有帮助!

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

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