I try to re-write a few of my older apps and want to start from scratch.
Basically I try to start from the "Empty Application" template, that just leaves me with a AppDelegate.m/.h and I need to make my own separation between iPad/iPhone.
Any idea how I do this in the AppDelegate?
In older Xcode versions, the program created separate delegates for iPad/iPhone.
When you have to handle things differently for iPhona and iPad, you can use the following to see on which one you are:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// Do things for iPad
} else {
// Do things for iPhone
}
So you can use different view delegates for either iPad or iPhone, or if they behave almost identically, you can use the same view delegate and use the previous test when necessary. As an example, you can modify the init method to load a different Xib file:
- (id)init
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
self = [super initWithNibName:@"ViewController_iPad" bundle:nil];
} else {
self = [super initWithNibName:@"ViewController_iPhone" bundle:nil];
}
if (self) {
// Custom initialization
}
return self;
}
You can do similar things in shouldAutorotateToInterfaceOrientation
etc.