I tried in the app delegate Using BOOL and having trouble. I tried the device check in the mainViewController class (id)initWithNibName: (NSString *)nibNameOrNil bundle: (NSBundle *)nibBundleOrNil I returned a different nib based on the device type. But I can only get iPhone Version or blank nib. Thank you in advance for your help.
myNibName~ipad.xib and myNibName~ iphone.xib so each file can only be opened on supported devices. You don’t even need to set different appDelegates
—From doc—
In iOS 4.0 and later, individual resource files can be marked as available only on specific types of devices. This feature simplifies the code you have to write for Universal apps. Instead of creating a separate code path to load one version of the resource file for the iPhone and different versions for the iPad, you can let the bundled loading routine choose the correct file. All you have to do is to name your resource file appropriately.
To associate a resource file with a specific device, please add a custom modifier string to its file name. Including this modifier string will produce a file name with the following format:
.
This string represents the original name of the resource file. It also represents the name used when accessing the file from code. Similarly, the string is a standard file extension used to identify the file type. The The string is a case-sensitive string and can be one of the following values:
~ipad-resources can only be loaded on iPad devices. ~iphone-resources can only be loaded on iPhone or iPod touch devices .
So I am writing an application and I want it to be universal. When I create the project, I create a universal application. I I have written all the iPhone code, and there are 10 classes. Now I want to create the iPad version. I want to load different Nibs based on the device type, instead of having two sets of basically the same code.
I tried to use BOOL in the app delegate and ran into trouble. I tried the device check in the mainViewController class (id)initWithNibName: (NSString *)nibNameOrNil bundle: (NSBundle *)nibBundleOrNil I returned a different according to the device type Nib. But I can only get the iPhone version or the blank nib. Thank you in advance for your help.
According to the documentation (Resource Programming Guide), you can Use name conventions, such as:
myNibName~ipad.xib and myNibName~ iphone.xib so each file can only be opened on supported devices. You don’t even need to set different appDelegates
—From doc—
In iOS 4.0 and later, individual resource files can be marked as available only on specific types of devices. This feature simplifies the code you have to write for Universal apps. You can let Bundle the loading routine to select the correct file, instead of creating a separate code path to load one version of the resource file for the iPhone and different versions of the file for the iPad. All you have to do is to name your resource file appropriately.
To associate a resource file with a specific device, please add a custom modifier string to its file name. Including this modifier string will produce a file name with the following format:
.
This string represents the original name of the resource file. It also represents the name used when accessing the file from code. Similarly, the string is a standard file extension used to identify the file type. This string is A case-sensitive string, which can be one of the following values:
~ipad – resources can only be loaded on iPad devices. ~iphone – resources can only be loaded on iPhone or iPod touch devices.
p>