自定义关系Segue

时间:2014-08-22 05:36:30

标签: ios segue uistoryboard

由于无法使用IBOutlets连接故事板中的场景,因此segues将是一个很好的方式。

虽然创建自定义细分很容易,但似乎无法创建自定义"关系细分"。

enter image description here

是吗?是这样吗? 只有Apple可以创建这样的细分(UITabBarController' viewControllersUINavigationController' s rootController等?)

2 个答案:

答案 0 :(得分:2)

你是对的,你不能创建自定义关系segues。

关系segues与其他segues的不同之处在于它们在构建时被解析。当从故事板加载UITabBarController时,它的所有组成视图控制器已经在同一个NIB中“内部”,表示具有标签栏控制器的场景。

答案 1 :(得分:1)

现在我们可以做到这一点!

enter image description here

只需创建一个自定义UIStoryboardSegue子类,然后它就可以在Interface Builder中使用。

结果与创建" Custom"相同。 segue并将其类设置为您的子类。

KWDrawerController库中的一个示例:

public class DrawerEmbedRightControllerSegue: UIStoryboardSegue {

    final public override func perform() {
        if let sourceViewController = source as? DrawerController {
            sourceViewController.setViewController(destination, for: .right)
        } else {
            assertionFailure("SourceViewController must be DrawerController!")
        }
    }

}
相关问题