Xib for iPhone and iPad

馋奶兔 提交于 2019-12-04 10:10:14

I ended up using 1 class. I set the file owner of both XIB files to this same class.

I just used the name of the XIB file

So I have 2 xibFiles, iPadXib.xib and iPhoneXib.xib

NSString *nibFileName = (iPadVersion) ? @"iPadXib" : @"iPhoneXib";

ViewControllerName *vc = [[ViewControllerName alloc] initWithNibName:nibFileName bundle:nil];

Or do I need to be make 2 Xib files and 2 classes?

Actually, use three classes and 2 xibs. Like this:

  1. MyClass
  2. MyClass_iPhone: MyClass
  3. MyClass_iPad: MyClass

And the two xibs. It gives you much more flexibility. Keep the common logic on the MyClass, and sub-class the other two for the iPhone and iPad Version.

Vineesh TP

If you want both iPhone and ipad Create Universal App. Create only One XIB and create all controls only once not need to do it separately. Draw the frame in coding. ie, Create frame separate for both iphone and ipad.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!