Reputation: 301
I have to develop an application for both ios phones and tablets. The application logic is the same, while the UI is completely different. I'm wondering how I should deal with this: make 1 big app for both, or an app for phone and an app for tablet (and then upload the 2 ipa's as 1 app in the market).
When I make 1 application, I should check if it's phone or tablet in code to redirect to the appropriate activity. Also I should include compatibility code to make it compile for phones. If I would make 2 apps, I don't need that check and I also don't need to include the compatibility code, so the app would be a lot smaller. But in that case I'll have to copy/paste the application logic constantly from one project to the other one while development.
So that's why I'm wondering, what's the best practice in this case? I've been searching for information about this, but I only find articles about how to manage the different xml layouts, or articles with not so much information in it.
i googled and found theres an article for android here Android app for phone and tablet: 1 or 2 apps?
But i need to know about ios apps
Upvotes: 2
Views: 1415
Reputation: 2163
Put this code into your app delegate class and
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UINavigationController *navController;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
_iPhonehomeScreen = [[NFHomeScreen_iPhone alloc] initWithNibName:@"NFHomeScreen_iPhone" bundle:nil];
navController = [[UINavigationController alloc] initWithRootViewController:_iphonehomeScreen];
[navController setNavigationBarHidden:YES];
self.window.rootViewController = navController;
}
else {
_iPadhomeScreen = [[NFHomeScreen_iPad alloc] initWithNibName:@"NFHomeScreen_iPad" bundle:nil];
navController = [[UINavigationController alloc] initWithRootViewController:_iPadhomeScreen];
[navController setNavigationBarHidden:YES];
self.window.rootViewController = navController;
}
[navController release];
}
now use two xib for iPad and iPhone with common .h and .m file for same.
Upvotes: 1
Reputation: 75077
It's really more of a marketing question if you want to build two apps, or a universal app. Do you want users to be able to buy just once and run on both platforms? Does the iPad version do so much more you'd rather charge a premium?
Once you've decided that it's easy to share code where needed, if you have two seperate applications you can make a target for the iPad, and a target for the iPhone - each target can share whatever code or resources or data models that you like. it's also a good idea to have just a bare minimum app delegate that the iPad and iPhone versions inherit from.
If it's universal you may well end up with some checks for which platform you are on, but generally once you load up the main interface files you don't need to do much detection beyond that.
Upvotes: 2