在我的应用程序中,我有以下 Storyboard片段:
从粉红色按钮,我在右侧的 UIViewController 中添加了一个名为“toFishPic”的显示转场。这是链接到粉红色按钮的快速代码:
@IBAction func toFishPhoto(sender: UIButton) {
dispatch_async(dispatch_get_main_queue()) {
self.performSegueWithIdentifier("toFishPic", sender: self)
}
}
我不知道为什么,但是当点击粉红色按钮时,右侧的 UIViewConroller(带有大 UIImageView 的那个)被加载了两次,就好像它后面有一个相同的一样。为什么会这样?
最佳答案
我认为您将粉红色按钮直接链接到 PhotoViewController,而不是将 ActionFishViewController 链接到 PhotoViewController。如果您要使用 performSegueWithIdentifier,请不要直接链接并在 Controller 之间重新连接。
尽量不要调用 self.performSegueWithIdentifier("toFishPic", sender: self) (//) 并检查是否可以推送到 PhotoViewController。如果它有效意味着您将按钮直接链接到 PhotoViewController。
关于Swift:为什么 "performSegueWithIdentifier"会发生两次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33898813/