1

嘿,

我有一个普通的spitviewapplication,有1个master和1个detail,为了在两者之间进行通信,我在appDelegate中设置了这个代码:

UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;

UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
ImageGaleryViewController *rightViewController = (ImageGaleryViewController *)navigationController.topViewController;
splitViewController.delegate = (id)navigationController.topViewController;

UINavigationController *masterNavigationController = splitViewController.viewControllers[0];
CatalogPopUpViewController *controller = (CatalogPopUpViewController *)masterNavigationController.topViewController;
controller.delegate = rightViewController;

现在我想制作第二个主控并能够在它们之间切换细节,比如有两个按钮并单击一个打开 1s 主控另一个按钮打开第二个主控,但也希望能够从主控到细节通信,设置一个委托,我可以制作一个新的视图控制器并制作一个segue以替换为master,但是我该如何设置委托?从大师到细节的沟通?我希望我能理解我的问题。

4

1 回答 1

0

我知道了,我用过

[self performSegueWithIdentifier:@"catalogMasterSegue" sender:self];

调用主人,segue然后准备segue:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([[segue identifier] isEqualToString:@"catalogMasterSegue"])
    {
        CatalogPopUpViewController *controller=[[[segue destinationViewController]viewControllers]objectAtIndex:0];
        controller.delegate=self;
    }
}
于 2013-11-12T15:15:15.240 回答