0

我需要创建一个拆分视图应用程序,该应用程序从我手动自定义的基本视图开始。然后我需要转换到 SplitView 或将主/详细表视图推送到堆栈以实现电话。

我计划使用的策略是将基本视图放置到 SplitView 控制器的详细信息窗格中,而当它在那里时,只需在其各自的方向上隐藏左窗格的侧面板和按钮。

有没有更好的办法?我可以使用“普通”视图作为我的根视图,然后以编程方式将其切换到 UISplitView 吗?

对于手机版本 - 这不是一个真正的问题。由于导航控制器是根视图控制器 - 我可以将更多视图推送到堆栈上。

对于 iPad - 您不能将 UISplitView 控制器推送到导航堆栈上。我真的很想这样做,所以我有一些“后退”的概念。我可以以编程方式创建它 - 但在我这样做之前 - 如果存在其他选项,我会对它们感兴趣。

我想为这个应用程序使用故事板——目标版本是 iOS 5——用于 ARC。

4

2 回答 2

1

试试这个代码:您可以将您的 LoginViewcontroller 添加为 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"];
于 2013-06-07T11:47:21.570 回答
1

我通过替换应用程序的根目录来做到这一点。作为第一个屏幕,我有一个LoginViewController,当登录成功时,ViewControllerUISplitViewController. 你也可以做这个动画。

编辑:

这是我的UIStoryboardSegue子类代码:

- (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){
                    }];
}
于 2013-06-07T11:41:52.353 回答