performSegue 动画完成,什么标识符?

performSegue on animation finished, what identifier?

我想在动画完成时执行从加载 viewController 到下一个 viewController 的转场:

override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)

    UIView.animateWithDuration(1.5, delay: 0.5, options: UIViewAnimationOptions.CurveLinear, animations: {
        self.loggo_image.alpha = 1.0

        self.performSegueWithIdentifier("LogInView", sender: nil)
        }, completion: nil)

}

我知道代码本身可能是错误的,但它只是显示示例。由于我没有任何按钮或类似按钮来创建到情节提要中下一个视图的转场(CTRL 在情节提要中单击),我想我需要以编程方式进行。虽然我不知道如何设置我想去的视图的 "identifier"。如示例所示,我尝试简单地使用自定义 class 名称,这是不正确的。

那怎么办?是故事板 ID 吗?标题?

您可以 Ctr-Drag 从 ViewController 本身(屏幕截图上的黄色圆圈)到您要转到的 viewcontroller。

它将创建一个 segue,您可以在那里设置它的标识符,然后使用您在情节提要中设置的标识符像您一样调用 performSegue

让我们来解决您的问题:

I want to perform a segue from my loading viewController to the next viewController when an animation is finished

当动画完成意味着代码错误(你说"I know the code itself probably is wrong"是对的),你应该在completion块,如下:

UIView.animateWithDuration(1.5, delay: 0.5, options: UIViewAnimationOptions.CurveLinear, animations: {
            self.loggo_image.alpha = 1.0
            }, completion: { _ in
                self.performSegueWithIdentifier("LogInView", sender: nil)
        })

Though I can't work out how to set the "identifier" of the view I want to go to. As shown in the example, I tried simply using the custom class name, which isn't right.

So how? Is it Storyboard ID? Title?

我在 .

中详细描述了如何准确地实现这一点

另外:

如果您遇到需要在不使用 segues 的情况下导航到另一个 viewController 的情况,请检查这个(在这种情况下您必须使用 Storyboard ID):

let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

// "nextView" is Storyboard ID
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("nextView") as NextViewController

// now you can choose between pushing:
self.navigationController?.pushViewController(nextViewContro‌​ller, animated: true)
// or presenting:
self.presentViewController(nextViewController, animated:true, completion:nil)

希望对您有所帮助。