0

希望有人可以提供帮助。

我有一个使用的应用程序,UISplitViewController但是我现在不得不开始使用多个storyboards,因为我有大量的viewsXcode 开始运行非常慢。我已将 移动UIViewControllers到多个storyboards.

Master View是由静态单元格构建的,因此当用户选择单元格时,我通常会通过viewsegue.

我现在想知道如何以编程方式更改 a 的详细视图UISplitViewController

谢谢

4

1 回答 1

4

子类 UISplitViewController 并将您的根 splitViewController 设置为该类。然后将此方法添加到您的 UISplitViewController 子类中:

-(void)setDetailControllerTo:(UIViewController *)detailController withNavControllerTitle:(NSString *)title {
    [detailController view]; // this line forces the viewDidLoad method to be called

    if (title) {
        UINavigationController *navController = [[UINavigationController alloc] init];
        [navController pushViewController:detailController animated:YES];
        detailController.title = title;

        NSArray *viewControllers=@[self.mainController.viewControllers[0],navController];
        self.mainController.viewControllers = viewControllers;
    } else {
        NSArray *viewControllers=@[self.mainController.viewControllers[0],detailController];
        self.mainController.viewControllers = viewControllers;
    }
}

要调用此方法,请从主视图控制器执行以下操作:

FixedSplitViewController *splitController = (FixedSplitViewController*) self.splitViewController;

CurrentEventViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"CurrentEventViewController"];
// add any setup code here
[splitController setDetailControllerTo:controller withNavControllerTitle:@"Current Event"];

我的很多项目都需要 splitviewcontroller 始终显示主视图,所以我使用这个子类来防止主视图在纵向旋转时隐藏。

于 2013-11-08T13:12:22.260 回答