开发者

precompiler for ipad

HI all,

In xcode I am trying to load different nib file in case I am using iphone/ipod or ipad.

I have a Define.h file with all enum and constants in it, so I would like to put in there a kind of (obviously wrong because I don't know how to do it):

#if IPHONE  // <-- can I intercept the Active Executable here ?
  #define MY_VIEW @"TableViewIphone.xib"
#else
  #define MY_VIEW @"TableView开发者_运维百科Ipod.xib"
#endif 

Then in my view controllers which include Define.h

[[NSBundle mainBundle] loadNibNamed:MY_VIEW owner:self options:nil];

I am in need of doing this with device simulator, is there a way to intercept what's in "Active Executable" in xcode and have a specialized set of define ? Are there any other and easier alternatives ?

thanks


What you want to do is select a xib at run-time, appropriate for the device.

What you are doing is a compile-time selection, which will set the xib to be used for all devices, which is not what you want.

I'm assuming you're building a Universal app, yes?

I prefer to have the device load the appropriate xib when my app is launched by using the proper key in my app's Info.plist file, which is the key NSMainNibFile~ipad. (e.g. I set NSMainNibFile~ipad to MainWindow-iPad... note: no ".xib" bit)

Another alternative is to use the UI_USER_INTERFACE_IDIOM macro:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    // Load iPad xib
}
else
{
    // Load iPhone xib
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜