How to dynamically move between two view controllers in Objective C - iOS,Xcode

This code show how to move between two view controllers dynamically.To do this we need to catch what is the user device the app is running. It shold be either iPhone or iPad.

Below I have explain the code well.

01. Define a string with default value as 
NSString *storyboardTypeName = @"Main_iPhone";

if([[UIDevice currentDevice].model  isEqualToString:@"iPhone"]){ storyboardTypeName = @"Main_iPhone";}else if([[UIDevice currentDevice].model isEqualToString:@"iPad"]){ storyboardTypeName = @"Main_iPad";}UIStoryboard *storyboard1 = [UIStoryboard storyboardWithName:storyboardTypeName bundle: nil];UIViewController *controller = [storyboard1 instantiateViewControllerWithIdentifier:@"termsnConditionVC"];[self.navigationController pushViewController:controller animated:YES];


Happy coding

Comments

Popular Posts