views:

1617

answers:

1

Hi,

I usually create my projects without IB-stuff. The first thing I do is to strip off all references to xibs, outlets updated plist, etc and so forth. No problems, works great (in my world)!

Now, I just installed 3.2 and tried to develop my first iPad app. Following same procedure as before, I created a UISplitView-based application project and stripped off all IB-stuff. Also, I followed the section in Apple's reference docs: "Creating a Split View Controller Programmatically", http://bit.ly/axgYAs, but nevertheless, the Master-view is never shown, only the Detail-view is (no matter what the orientation is). I really have tried to carefully look this through but I cannot understand what I have missed.

Is there a working example of a UISplitViewController without the nibs floating around somewhere? I have googled but could not find any. Or do you know what I probably have missed?

Regards, /Steve

PS. Spare me the lesson why I should use the IB ;-) DS.

+1  A: 

Declare your splitviewcontroller in your delegate header, use something like this in your didfinishlaunching

ensure you add the UISplitViewControllerDelegate to the detailedViewController header file and that you have the delegate methods aswell. remember to import relevant header files

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

splitViewController = [[UISplitViewController alloc] init];

rootViewController *root = [[[rootViewController alloc] init] autorelease];
detailedViewController *detail = [[[detailedViewController alloc] init] autorelease]; 

UINavigationController *rootNav = [[[UINavigationController alloc] initWithRootViewController:root]autorelease];

UINavigationController *detailNav = [[[UINavigationController alloc] initWithRootViewController:detail] autorelease];

splitViewController.viewControllers = [NSArray arrayWithObjects:rootNav, detailNav, nil];
splitViewController.delegate = detail;


[window addSubview:splitViewController.view];

[window makeKeyAndVisible];

return YES;

}

//detailedView delegate methods
- (void)splitViewController:(UISplitViewController*)svc 
     willHideViewController:(UIViewController *)aViewController 
          withBarButtonItem:(UIBarButtonItem*)barButtonItem 
       forPopoverController:(UIPopoverController*)pc
{  
    [barButtonItem setTitle:@"your title"];



    self.navigationItem.leftBarButtonItem = barButtonItem;
}


- (void)splitViewController:(UISplitViewController*)svc 
     willShowViewController:(UIViewController *)aViewController 
  invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
    self.navigationItem.leftBarButtonItem = nil;
}

I also prefer code to IB ;-)

Burnsoft Ltd