多个 segues 到一个视图控制器(如何让它在故事板中看起来不错)

Multiple segues to one view controller (how to make it look nice in storyboard)

这是我的 storyboard 图片:

我想创建 segue 到 viewController 红色箭头所指的位置。这是个人资料 viewController。最终可能会有三个 viewControllers 链接到此 viewController。目前会有两个。

现在我可以简单地控制拖动显示并创建转场。然而,这看起来很乱。我的 storyboard 现在这条对角线在 viewControllers 下方。

这是执行此操作的预期方式吗?一条线从一条线延伸到另一条线是完全正常的吗??

提前感谢您的回答。

你实际上可以只从情节提要中添加 segue,即使使用对角线也可以。只是不适合眼睛。

如果你不想让你的故事板变得凌乱,你可以将配置文件控制器放在故事板的另一部分,然后直接调用它而不使用 segues。

if let vc = UIStoryboard(name: "MyStoryboard", bundle: nil).instantiateViewControllerWithIdentifier(identifier: "viewControllerId") {
    // Present or push the view controller using the proper function
}

要设置视图控制器标识符,您只需在故事板上单击它并填写身份检查器中的 "Storyboard ID" 字段。

事实上,您可以随时使用 segue 或故事板 ID 将您的应用程序导航到任何 viewCotroller。但是这里有一个预定义的规则,你必须知道关于 viewController's 堆栈,每当你加载任何 viewController 时,它们都会出现在堆栈中,该堆栈遵循 先进后出 方式。

您可以使用 segue 来导航您的 viewConteollerstoryboard ID

Objective c:

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"viewsId"];

// Note: use presentViewController or pushViewController one of them    
[self presentViewController:vc animated:YES completion:nil];

[self.navigationController pushViewController:vc animated:YES];

在Swift中:

let vc: UIViewController =  (self.storyboard?.instantiateViewControllerWithIdentifier("viewsId"))!

// Note: use presentViewController or pushViewController one of them
    self.presentViewController(vc, animated: true, completion: nil)

    self.navigationController?.pushViewController(vc, animated: true)