iOS segue executed twice

两盒软妹~` 提交于 2019-12-03 06:14:39

Maybe you want to wire up your segues with View Controllers instead of UIButtons!

You should probably have the segues wired with some button like this:

But you should wire them with the view controllers instead:

Answer by can poyrazoğlu:

are you sure you've wired up the actions correctly in interface builder? maybe you've wired the event for, say, both touch up inside and touch down inside instead of just touch up inside. or maybe you've also assigned the segue from both code and again in interface builder. have you checked them? it's a common mistake. –

I was assigning the touch up inside actions for each button both the storyboard and my tableview's datasource methods.

Thank you for your quick help can poyrazoğlu!!

For Swift 3, xcode, and ios 9+, which is what I am using: Make sure you are drawing segue from your UIViewControllers and not buttons or other interfaces.

I had the same problem, and simply changing the start of the segue from the UIController instead of the button removed this bug.

I always get this issue when I have my buttons directly wired up to the destination view controller. You need to make sure that you first delete the old segue you made, then click on the present view controller (where you are coming from) and CTRL + click to destination controller.

This should fix it :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!