Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS equivalent to Android Fragments/Layouts

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.

like image 638
momo Avatar asked Jul 21 '12 12:07

momo


1 Answers

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];
like image 153
Sumanth Avatar answered Nov 15 '22 12:11

Sumanth