5

I'm making a universal app based on the Utility App template. I've selected a universal app and the MainView.xib and MainView~iPad.xib work properly on both device types.

On the iPad2, when I switch to the FlipsideView, it loads FlipsideView.xib even though there is a perfectly good FlipsideView~iPad.xib file in the project. The default xib is normal (iPhone) sized and displaying in the lower left hand corner of the iPad.

I did have to create the FlipsideView~iPad xib manually. I believe I have the xib properly wired in IB as it shows identical to the FlipsideView.xib connections.

Over the last couple weeks, I've read quite a few posts with similar problems and this Stack Overflow thread answers most clearly and contains links to Apple documentation. So I know it works for others and is documented.

The code for this section is identical to the showInfo() method in the stock Utility App template.

(Yes I realize I can manually load the ~iPad version checking UI_USER_INTERFACE_IDIOM(). I'm trying to figure out what I'm doing wrong in getting the ~iPad modifier to work.)

Any ideas what I'm missing?

Thanks a ton for your help!

Community
  • 1
  • 1

2 Answers2

27

in the end i found the solution. it is really very very simple. The xib must be named ~ipad instead of ~iPad, and ~iphone instead of ~iPhone. The bad thing is the if you name them ~iPad, everything works in the simulator but it does not work on the real device.

pdenti
  • 834
  • 10
  • 10
  • Thanks for the info! I am surprised it took me like an hour to find this! - using suffix ~iphone and ~ipad for automatic xib file selection for different device. – Hlung Feb 01 '12 at 18:27
  • Very useful, thanks. I had to Product -> Clean in xCode for this to work after renaming though. – glenstorey Mar 15 '12 at 08:31
  • 1
    The iOS file system is case-sensitive, but the Mac's file system is case-INsensitive. So the simulator's disk can't tell the difference, but the device's disk can. – Walt Sellers May 18 '12 at 20:26
  • Pay attention to image names as well. Simulator case-insensitive, phone case sensitive. Spent an hour figuring out why an image wasn't loading until i figured it out – TegRa Jun 29 '12 at 14:56
  • What about iPhone 5? I have used same convention(iphone5) but not working. – Nitin Jul 23 '13 at 06:24
0

It can be done automatically based on the name, no worries. The only problem is you'll need to switch your naming convention. MainView.xib will be your iPad xib and MainView~iphone.xib will be your iPhone xib. Then it should work perfectly for you and you don't have to do anything but alloc/init.

You can check out my other answer on this topic here: iOS: Using device modifiers for loading xib files?

Community
  • 1
  • 1
Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229