Dragging onto the exit of the viewcontroller not working

余生颓废 提交于 2019-11-27 16:49:51

问题


I have looked for this problem everywhere. I know how the unwind scene works. I have implemented the following code in the A VC

-(IBAction)returned:(UIStoryboardSegue *)segue {
try.text = @"Returned from Scene 1";
}

But when I go to my B VC(Which is the VC I want to go back to A VC from) and ctrl drag a button onto the exit at the bottom it will not allow me to. And no function pops up in the exits option. Anyone else had this issue or can help?


回答1:


To set up an unwind segue, you should

  1. Set up your two scenes with the standard modal or push segue between them:

  2. Define the custom classes for those two scenes to be your respective view controllers.

  3. Implement the action in the .m for view controller A:

    - (IBAction)unwindToA:(UIStoryboardSegue *)segue
    {
        //returning to A
    }
    
  4. Then you can create a segue in B by control-dragging (or right-click-dragging) from some control down to the exit outlet in the bar below scene B:

  5. And if everything above is configured correctly, you will now see your unwind segue listed in a popover:




回答2:


To make Exit outlet active, add this code to viewController. Now you should be able to ctrl-drag to exit outlet. It is actually quite odd, that there should be empty method to make it work.

swift
@IBAction func unwindSegue(unwindSegue:UIStoryboardSegue) 

objC
- (IBAction)unwindSegue:(UIStoryboardSegue *)sender;



回答3:


I also had a problem with this even though everything was set up correctly. Eventually I tried closing the project and reopening it and that did the trick. Must have been some bug in Xcode.

This doesn't seem to have been the cause of your problem but I thought I'd add the answer in case someone else has the same problem.




回答4:


@LoPoBo, @hozefam, & @Van Du Tran

If closing down isn't working, perhaps you were dragging in the wrong manner. Instead of clicking on the Bar Button Item and dragging from Action Segue to the exit try just right click -> hold & drag to exit segue. This was messing with me for a good 20min before I figured it out. Hope this helps someone else too. Using xcode 6.1



来源:https://stackoverflow.com/questions/15511153/dragging-onto-the-exit-of-the-viewcontroller-not-working

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