0
votes

I need to create a split view application that starts with basic view that I customize manually. Then I need to transition to the SplitView or push the master/detail table views onto the stack for the phone implementation.

The strategy I was planning to use would be placing the basic view into the detail pane on the SplitView controller, and while it was there just hide the side panel and button for the left pane in their respective orientations.

Is there a better way? Can I use a "plain" view as my root view, then switch it programmatically to a UISplitView?

For the phone version - this isn't really a problem. Since the navigation controller is the root view controller - I can just push more views onto the stack.

For the iPad - you cannot push a UISplitView controller onto the Navigation stack. I'd really like to do this so I have some concept of "back". I can create it programmatically - but before I do - I'd be interested in some other options if they exist.

I want to use Storyboards for this application - and the target version is iOS 5 - for ARC.

2
Have you tried by switching the rootViewController between your first viewcontroller and the spliviewcontroller?Mat
@Mat yes. That was one method I considered originally. It is well, crude, and doesn't play as well as I would like with using a storyboard. Realistically - I'll probably have to do that. I am going to try out some of the suggestions below which are basically doing just that.sylvanaar

2 Answers

1
votes

I've done this by replacing the root of the app. As first screen I had a LoginViewController, and when the login was successful, switched that ViewController with a UISplitViewController. You can do this animated too.

Edit:

Here is my code from the UIStoryboardSegue subclass:

- (void) perform
{
    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

    UIViewController *sourceViewController = (UIViewController *)self.sourceViewController;
    UISplitViewController *destinationViewController = (UISplitViewController *)self.destinationViewController;

    UIWindow *window = appDelegate.window;
    window.rootViewController = destinationViewController;
    window.rootViewController = sourceViewController;

    [UIView transitionWithView:sourceViewController.view.window
                      duration:0.5
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:^{
                        window.rootViewController = destinationViewController;
                    }
                    completion:^(BOOL finished){
                    }];
}
1
votes

try this code: you can add your LoginViewcontroller as A root view-controller in Delegate

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


        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

        self.viewController = [[LogInViewController alloc] initWithNibName:@"LogInViewController" bundle:nil];


         self.window.rootViewController = self.viewController;

           [self.window makeKeyAndVisible];
        return YES;

    }


and your loginButton Action:

    -(IBAction)loginclick:(id)sender
    {
         objAppdelegate = (yourProjectnameDelegate *) [[UIApplication sharedApplication]delegate];
         NSMutableArray *array = [NSMutableArray array];

                    HomeSpilitView = [[[UISplitViewController alloc] init]autorelease];

                    HomeMster = [[HomeSpilitViewController alloc] initWithNibName:@"HomeSpilitViewController" bundle:nil];

                    masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:HomeMster] autorelease];
                    HomeMster.title=@"Title home";
                    masterNavigationController.navigationBar.tintColor =[UIColor colorWithRed:255/255.0 green:108/255.0 blue:61/255.0 alpha:0.1];
                    [array addObject:masterNavigationController];


                    HomeDetailsViewController *HomeDetailsViewControllers = [[HomeDetailsViewController alloc] initWithNibName:@"HomeDetailsViewController" bundle:nil];

                    detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:HomeDetailsViewControllers] autorelease];

                    detailNavigationController.navigationBar.tintColor =[UIColor colorWithRed:255/255.0 green:108/255.0 blue:61/255.0 alpha:0.1];
                    HomeDetailsViewControllers.title=@"details title";
                    HomeMster.objHomeDetailsViewcontroller=HomeDetailsViewControllers;
                    HomeSpilitView.delegate = HomeDetailsViewControllers;

                  [array addObject:detailNavigationController];

                  [HomeSpilitView setViewControllers:array];

                  [objAppdelegate.window setRootViewController:HomeSpilitView];


    }


//===for animation


     UIInterfaceOrientation interfaceOrientation = HomeSpilitView.interfaceOrientation;
        NSString *subtypeDirection;
        if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
            subtypeDirection = kCATransitionFromTop;
        }
        else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
            subtypeDirection = kCATransitionFromBottom;
        }
        else {
            subtypeDirection = kCATransitionFromRight;
        }
        [objAppdelegate.window setRootViewController:HomeSpilitView];
        CATransition *animation = [CATransition animation];
        [animation setDuration:0.5];
        [animation setType:kCATransitionPush];
        [animation setSubtype:subtypeDirection];
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

        [[objAppdelegate.window layer] addAnimation:animation forKey:@"SwitchToView1"];