In my app(a sample app, upon success, gonna implement in my app) i am moving to viewController from my Appdelegate. In my ViewController.m, i am initialising a SplitViewController. But my code is not working.. I have given my appDelegate and ViewController codes..
Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = self.navigationController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
ViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
-(IBAction)btnClick:(id)sender
{
PopMenuViewController *menuVC = [[PopMenuViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *menuNavController = [[UINavigationController alloc] initWithRootViewController:menuVC];
PopMenuDetailViewController *detailVC = [[PopMenuDetailViewController alloc] initWithNibName:@"PopMenuDetailViewController" bundle:nil];
UINavigationController *detailNavController = [[UINavigationController alloc] initWithRootViewController:detailVC];
menuVC.detailViewController = detailVC;
splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = @[menuNavController, detailNavController];
//appdelegate.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//appdelegate.window.rootViewController = self.splitViewController;
[appdelegate.window addSubview:self.splitViewController.view];
}
Am not giving this code in AppDelegate because, in my real app, i need to implement splitviewcontroller concept only in my contacts page.. so i need to get splitViewController working when i click CONTACT button from my HOMEPAGE.. So can anyone help me with this?
SplitViewController should be at the root of the application. Instead of making NavigationController root view controller of the application , you should make SplitViewController its root.
My suggestion :
1. Learn more about SplitViewController. Check here.
2. Learn more about ViewControllers. Check this Programming Guide.