Swift:为什么"performSegueWithIdentifier"会发生两次?

Sag*_*usA 0 uibutton segue swift

在我的应用程序中,我有以下故事板片段:

在此输入图像描述

从粉红色的按钮我添加了一个名为"toFishPic"的show segue到了更高的UIViewController.这是链接到粉红色按钮的快速代码:

@IBAction func toFishPhoto(sender: UIButton) {

    dispatch_async(dispatch_get_main_queue()) {
        self.performSegueWithIdentifier("toFishPic", sender: self)
    }
}
Run Code Online (Sandbox Code Playgroud)

我不知道为什么,但是当点击粉红色按钮时,右侧的UIViewConroller(具有大UIImageView的那个)被加载两次,好像之后有一个相同.为什么会这样?

小智 5

我认为你直接将粉红色按钮链接到PhotoViewController而不是ActionFishViewController到PhotoViewController.如果您要使用performSegueWithIdentifier,请不要直接链接并重新连接控制器.

尝试不要调用self.performSegueWithIdentifier("toFishPic",sender:self)(//)并检查是否可以推送到PhotoViewController.如果它的工作意味着您将按钮直接链接到PhotoViewController.