Как реализовать SplitViewController на втором уровне.? - PullRequest
4 голосов
/ 19 октября 2011

Как реализовать SplitViewController на втором уровне.

На самом деле я хочу запустить приложение со страницей входа и после входа в систему. Мне нужен SplitViewController.

Ответы [ 2 ]

0 голосов
/ 24 января 2013

Для того же логина -> контроллер splitview, я делаю следующее:

а. Подкласс UIStoryboardSegue и переопределение 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

б. Добавьте "Custom Segue" из Initial View Controller в Destination и введите имя своего подкласса в поле свойства.

0 голосов
/ 18 мая 2012

Вот как я это делаю.Удалив первый viewContorller из окна и заменив его на 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];

Большинство строк здесь имеют дело с переходом и обработкой вращения.

self относится к первому ViewController, тогда какtheWindow относится к окну приложения.Вы можете добраться до него по: [self superView];

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...