2011-10-19 48 views
4

如何在第二級實現SplitViewController。如何在二級上實現SplitViewController。

其實我想要的是用登錄頁面和登錄後啓動應用程序。我需要SplitViewController。

+0

[這裏](http://stackoverflow.com/questions/4213097/best-way-to-switch-between-uisplitviewcontroller-and-other-view-controllers/25979945#25979945)是我如何處理這種情況,希望有所幫助。 – tadija

回答

0

這就是我的做法。通過從窗口中刪除第一個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];

0

對於相同的登錄 - > 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 

灣將「初始視圖控制器」中的「自定義塞格」添加到目標,並將您的子類名稱放在屬性字段中。

+0

是否必須在分割視圖之前創建單獨的視圖控制器,然後將其連接到splitviewcontroller?即時通訊試圖理解這一點,因爲我現在爲了讓它工作而在我的腦子裏停留了大約2天。我的故事板看起來像這樣:UINavigation> Login> SplitView> Uinavigation(masterview)/ MainDashboard(detailview)。我所做的就是將它從登錄中推出,但它什麼都不做。 – gdubs

相關問題