tags:

views:

67

answers:

1

Hi,

I am trying to navigate to a different view in the detailview of the splitviewcontroller. I dont want the new view to display in the split view.

I am using this code to change views. This works ok in portrait orientation, but in landscape the split view table view still appears. Can anyone help with this?

Next *any = [[Next alloc] initWithNibName:@"Next" bundle:nil];

[self.view addSubview:any.view];

A: 

You've got several options.

You could show Next as a modal view controller.
You could use a tab controller to switch between the split view and the Next view.
You could use some other container controller to switch between the split view and the Next view.

Without knowing anything else about your app, my guess is that you're showing Next in response to some user interaction in the detail view, so I'm guessing that presenting Next as a modal view controller is the best option. It's also the easiest.

Here's how to present Next as a modal view controller:

- (void) showNext
{
    Next* any = [[[Next alloc] initWithNibName:nil bundle:nil] autorelease];
    any.modalPresentationStyle = UIModalPresentationFullScreen;
    any.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:any animated:YES];
}

You can use different modalPresentationStyle & modalTransitionStyle values to get different effects.

To dismiss Next when you're done with it, you'll need to tell it's parentViewController to dismiss it. Just add this code to Next, and call it when you want to dismiss the Next view:

- (IBAction) dismiss
{
    [self.parentViewController dismissModalViewControllerAnimated:YES];
}

I usually want to call this sort of thing from a Close button somewhere, so I usually make it an IBAction.
IBAction is the same as void, but lets you hook up stuff easily in Interface Builder.

Paul Scott
Thks. I think this is what I want!
nishantcm