4

How to implement SplitViewController on second level.

Actually what i want is to launch app with a login page and after login. I need SplitViewController.

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
Rajesh Rajput
  • 263
  • 1
  • 11
  • [Here](http://stackoverflow.com/questions/4213097/best-way-to-switch-between-uisplitviewcontroller-and-other-view-controllers/25979945#25979945) is how I handled this kind of situation, hope that helps. – tadija Sep 24 '14 at 08:52

2 Answers2

0

This is how I do it. By removing the first viewContorller from the window and replacing it with the splitView

 splitViewController = [[SplitViewController alloc]init];
    // remove the current view and replace with splitViewController
    [theWindow addSubview:splitViewController.view];

    // Transition handling
    NSString *subtypeDirection;
    switch ([[UIApplication sharedApplication] statusBarOrientation]) {
        case UIDeviceOrientationPortrait:subtypeDirection = kCATransitionFromRight;break;
        case UIDeviceOrientationPortraitUpsideDown:subtypeDirection = kCATransitionFromLeft;break;
        case UIDeviceOrientationLandscapeLeft:subtypeDirection = kCATransitionFromTop;break;
        case UIDeviceOrientationLandscapeRight:subtypeDirection = kCATransitionFromBottom;break;
        default: NSLog(@"break at subType direction");break;
    }

    CATransition *animation = [CATransition animation];
    [animation setDuration:.5];
    [animation setType:kCATransitionPush];
    [animation setSubtype:subtypeDirection];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    [[theWindow layer] addAnimation:animation forKey:@"SwitchToSplitView"];

    [self.navigationController.view removeFromSuperview];

Most of the lines here deals with transition and handling rotation.

self refers to the first ViewController whereas theWindow refers to application window. You can get to it by:[self superView];

Byte
  • 2,920
  • 3
  • 33
  • 55
0

For the same login -> splitview controller I'm doing the following:

a. Subclass UIStoryboardSegue and override perform:

@implementation SSPushSegue

- (void)perform
{
    UIWindow* window = [self.sourceViewController view].window;

    // Transition handling
    NSString *subtypeDirection = kCATransitionFromRight;
    switch ([UIApplication sharedApplication].statusBarOrientation)
    {
        case UIDeviceOrientationPortraitUpsideDown: subtypeDirection = kCATransitionFromLeft; break;
        case UIDeviceOrientationLandscapeLeft: subtypeDirection = kCATransitionFromTop; break;
        case UIDeviceOrientationLandscapeRight: subtypeDirection = kCATransitionFromBottom; break;
        default: break;
    }

    CATransition *animation = [CATransition animation];
    animation.duration = .5;
    animation.type = kCATransitionPush;
    animation.subtype = subtypeDirection;
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    [window.layer addAnimation:animation forKey:NSStringFromClass([self class])];

    window.rootViewController = self.destinationViewController;
}

@end

b. Add "Custom Segue" from Initial View Controller to Destination and put your subclass name in the property field.

sunnycows
  • 125
  • 5
  • did you have to create a separate view controller before the split view and then connect it to the splitviewcontroller? im trying to understand this as ive been racking my brain for about 2 days now to make it work. my storyboard looks like this UINavigation > Login > SplitView > Uinavigation(masterview) / MainDashboard(detailview). What i did was to push it from the login but it doesnt do anything. – gdubs Feb 06 '13 at 04:07