xcode 拖动到视图控制器的出口不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15511153/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Dragging onto the exit of the viewcontroller not working
提问by Sfocker
I have looked for this problem everywhere. I know how the unwind scene works. I have implemented the following code in the A VC
我到处寻找这个问题。我知道放松场景是如何运作的。我已经在 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?
但是当我去我的 B VC(我想从哪个 VC 回到 A VC)并按住 ctrl 将一个按钮拖到底部的出口上时,它不允许我这样做。并且退出选项中没有弹出任何功能。其他人有这个问题或可以提供帮助吗?
回答by Rob
To set up an unwind segue, you should
要设置放松转场,您应该
Set up your two scenes with the standard modal or push segue between them:
Define the custom classes for those two scenes to be your respective view controllers.
Implement the action in the .m for view controller A:
- (IBAction)unwindToA:(UIStoryboardSegue *)segue { //returning to A }
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
:And if everything above is configured correctly, you will now see your unwind segue listed in a popover:
使用标准模态设置您的两个场景或在它们之间推动转场:
将这两个场景的自定义类定义为您各自的视图控制器。
在视图控制器 A 的 .m 中实现操作:
- (IBAction)unwindToA:(UIStoryboardSegue *)segue { //returning to A }
然后,您可以通过control从某个控件向下拖动(或右键单击拖动)到场景下方栏中的出口出口,在 B 中创建一个转场
B
:如果以上所有内容都配置正确,您现在将在弹出窗口中看到您的 unwind segue:
回答by Mantas Laurinavi?ius
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.
要使 Exit 出口处于活动状态,请将此代码添加到 viewController。现在您应该可以按住 ctrl-drag 退出出口。实际上很奇怪,应该有空方法来使它工作。
swift
@IBAction func unwindSegue(unwindSegue:UIStoryboardSegue)
objC
- (IBAction)unwindSegue:(UIStoryboardSegue *)sender;
回答by LoPoBo
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.
即使一切都设置正确,我也遇到了这个问题。最终我尝试关闭该项目并重新打开它,这成功了。一定是 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.
这似乎不是您的问题的原因,但我想我会添加答案,以防其他人遇到同样的问题。
回答by Brendan Robertson
@LoPoBo, @hozefam, & @Van Du Tran
@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
如果关闭不起作用,则可能是您拖拽的方式不对。而不是单击Bar Button Item
并拖动Action Segue
到exit
尝试只需右键单击 - >按住并拖动到exit segue
。在我弄明白之前,这已经困扰了我 20 分钟。希望这对其他人也有帮助。使用 xcode 6.1