Search code examples
objective-cipadxcode4.2master-detail

How to fill the screen with DetailViewController


I created a project using Master-Detail Application template but i don't need a MasterView. So i deleted Masterview files and codes but this time when i rotate the Simulator/Device in the left side of my main screen a black area stays. I want to stretch my Detail view to fill all the scren but i have no idea how to do. Can anyone please help? Thanks in advance

Note: My app needen NavigationController, firstly i tried SingleView template, but i couldn't push views on that template so i created my app in Master-Detail Application template..


Solution

  • - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        // Override point for customization after application launch.
            BNT_DetailViewController *detailViewController = [[[BNT_DetailViewController alloc] initWithNibName:@"BNT_DetailViewController" bundle:nil] autorelease];
         UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
    
         self.splitViewController = [[[UISplitViewController alloc] init] autorelease];
         self.splitViewController.delegate = detailViewController;
         self.splitViewController.viewControllers = [NSArray arrayWithObjects:detailNavigationController, nil];
         self.window.rootViewController = self.splitViewController;
         [self.window makeKeyAndVisible];
    
    
        BNT_DetailViewController *detailViewController = [[[BNT_DetailViewController alloc] initWithNibName:@"BNT_DetailViewController" bundle:nil] autorelease];
         navigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
    
    
           self.window.rootViewController = self.navigationController;
        [self.window makeKeyAndVisible];
        return YES;
    }
    

    This was the first appearance of the didFinishLaunchingWithOptions:of my ..AppDelegate.m but i changed it with below:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    
        //define navigationController in ..AppDelegate.h 
        BNT_DetailViewController *detailViewController = [[[BNT_DetailViewController alloc] initWithNibName:@"BNT_DetailViewController" bundle:nil] autorelease];
         navigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
    
    
           self.window.rootViewController = self.navigationController;
        [self.window makeKeyAndVisible];
        return YES;
    }
    

    I answered my own answer in case it may be helpful for someone who lives the same pains:)