Xib for iPhone and iPad

I have Xib for the iPhone, and I need a similar look for the iPad, only the size of the iPad.

What is the best way to do this? Can you put both views in the same Xib and somehow indicate which one is shown?

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

+4
source share
3 answers

In the end, I used 1 class. I set the file owner of both XIB files to the same class.

I just used the xib file name

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

NSString *nibFileName = (iPadVersion) ? @"iPadXib" : @"iPhoneXib"; ViewControllerName *vc = [[ViewControllerName alloc] initWithNibName:nibFileName bundle:nil]; 
+4
source

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

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

  • Myclass
  • MyClass_iPhone: MyClass
  • MyClass_iPad: MyClass

And two xibs. This gives you great flexibility. Keep common logic in MyClass and a subclass for two other versions of iPhone and iPad.

+2
source

If you want both iPhone and ipad Create a universal application. Create only one XIB and create all the controls only once, you do not need to do this separately. Draw a frame in encoding. those. Create a frame separately for iphone and ipad.

+1
source

Source: https://habr.com/ru/post/1447516/


All Articles