6

In Android you can use Fragments to develop only one app targeted to phones and tables, so you can have different UI. You can even use only Layouts and have some condition on the code to run tablet or phone logic.

I need to develop an app for iPhone and iPad and I wonder if there is something similar for implementing different UIs and slighty different behavior. In my case the iPhone app would use tabs at the bottom of the screen, but the iPad one should use the menu on the left side.

momo
  • 3,404
  • 6
  • 37
  • 66

2 Answers2

2

Yes you can use Different UI for iPhone and iPad. Create Two XIB files and when showing them on the screen use this condition to initiate the XIB

UIViewController *viewController;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
} else {
    viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
}
[self.navigationController pushViewController:viewController animated:YES];
Sumanth
  • 4,913
  • 1
  • 24
  • 39
  • I guess using this technique I could take care of the small differences on logic on the controller, right? I want to avoid duplicating code yet have sligthy different behavior on occasions. – momo Jul 21 '12 at 12:32
  • @momo this is the way I also do it. – huesforalice Aug 13 '12 at 14:13
0

UIViewController and XIB, respectively.

Also see Creating a Universal App.

Ken
  • 30,811
  • 34
  • 116
  • 155