Reputation:
I have been looking around at tutorials on how to make an iPhone app universal, so that it work on iPad. However when I have tried to implement this I've become a bit stuck since Xcode has changed a fair amount and the tutorials seem out of date. So far I have done the following:
I updated the devices to be set to Universal:
I have also updated my app delegate class like so:
// Set up tab 1
TabOne_ViewController *tabOne = [TabOne_ViewController alloc];
UIViewController *tabOneViewController;
// Set up tab 2
TabTwo_ViewController *tabTwo = [TabTwo_ViewController alloc];
UIViewController *tabTwoViewController;
// Determine which UI to load for each tab
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
tabOneViewController = [tabOne initWithNibName:@"TabOne_ViewController" bundle:nil];
tabTwoViewController = [tabTwo initWithNibName:@"TabTwo_ViewController" bundle:nil];
}
else
{
tabOneViewController = [tabOne initWithNibName:@"TabOne_ViewController(iPad)" bundle:nil];
tabTwoViewController = [tabTwo initWithNibName:@"TabTwo_ViewController(iPad)" bundle:nil];
}
I have also created two extra .xib files:
Finally I tried to set the class on TabOne_ViewController(iPad).xib
to be TabOne_ViewController.h
& TabOne_ViewController.m
. And also TabTwo_ViewController(iPad).xib
to be TabTwo_ViewController.h
& TabTwo_ViewController.m
. However I wasn't able to do so.
Have I gone wrong somewhere? Are there extra steps I have missed out?
EDIT:
When I was referring to not being able to select the class I mean in IB:
Without being able to link the class to the .xib file I can't link up all of the IBOutlets & IBActions.
Upvotes: 1
Views: 368
Reputation: 90117
In the xib you tried to change the class of the View. But you have to change the class of File's Owner
Upvotes: 1
Reputation: 717
you go to target click on project,give in summery: Device: "Universal"
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
tabOneViewController = [tabOne initWithNibName:@"TabOne_ViewController" bundle:nil];
tabTwoViewController = [tabTwo initWithNibName:@"TabTwo_ViewController" bundle:nil];
}
else
{
tabOneViewController = [tabOne initWithNibName:@"TabOne_ViewController(iPad)" bundle:nil];
tabTwoViewController = [tabTwo initWithNibName:@"TabTwo_ViewController(iPad)" bundle:nil];
}
Instead of this code you try this code as follows:
UIDevice* thisDevice = [UIDevice currentDevice];
if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
// iPad
tabOneViewController = [tabOne initWithNibName:@"TabOne_ViewController(iPad)" bundle:nil];
tabTwoViewController = [tabTwo initWithNibName:@"TabTwo_ViewController(iPad)" bundle:nil];
}
else
{
// iPhone
tabOneViewController = [tabOne initWithNibName:@"TabOne_ViewController" bundle:nil];
tabTwoViewController = [tabTwo initWithNibName:@"TabTwo_ViewController" bundle:nil];
}
Upvotes: 1