适用于iPhone和iPad的Xib

适用于iPhone和iPad的Xib

问题描述:

我有一个适用于iPhone的Xib,我需要一个类似于iPad的视图,只需要iPad尺寸。

I have a Xib for iPhone and I need a similar view for iPad, only iPad size.

这样做的最佳方式是什么?你可以将两个视图放在同一个Xib中,并以某种方式指定显示哪个视图?

What is the best way of doing this? Can you put both views in the same Xib and somehow specify which one is shown?

或者我需要制作2个Xib文件和2个类吗?

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

我最终使用了1节课。我将两个XIB文件的文件所有者设置为同一个类。

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

我刚使用了XIB文件的名称

I just used the name of the XIB file

所以我有2个xibFiles,iPadXib.xib和iPhoneXib.xib

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

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

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