iOS 6 - 以编程方式触发Unwind Segue什么都不做 [英] iOS 6 - programmatically triggering Unwind Segue does nothing

查看:130
本文介绍了iOS 6 - 以编程方式触发Unwind Segue什么都不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序启动时,它以编程方式显示使用segue的LoginViewController。视图控制器以模态方式呈现,过渡设置为交叉溶解。验证成功后,我想通过以编程方式触发展开segue来关闭登录视图。所以我把它添加到我的头文件中:

On my app's start up, it programmatically shows a LoginViewController using a segue. The view controller is presented modally with transition set to cross dissolve. Upon successful authentication, I want to dismiss the login view by programmatically triggering an unwind segue. So I added this to my header file:

- (IBAction)unwindSegue:(UIStoryboardSegue *)segue;

现在在IB中我可以控制 - 从文件所有者LoginViewController拖动到退出按钮并选择 unwindSegue:。这会创建一个手动segue,它会在Connections检查器中显示File文件的Owner和Exit按钮。然后,我从IB中的场景中单击新创建的Unwind segue,然后为其命名。如果我单击转到按钮进行展开segue操作,它会将我带到上面提到的声明。

now in IB I'm able to control-drag from the "File's Owner" LoginViewController to the Exit button and choose unwindSegue:. This creates a manual segue, it shows up in the Connections inspectors for the File's Owner and the Exit button correctly. I then click on the newly created Unwind segue from the scene in IB and then give it a name. If I click on the "go to" button for the unwind segue action it takes me to the declaration mentioned above.

到目前为止这么好,然后触发这个展开segue在我的GCD块中成功验证后:

So far so good, I then trigger this unwind segue upon successful authentication in my GCD block:

....
dispatch_async(dispatch_get_main_queue(), ^
{
    [self performSegueWithIdentifier:@"UnwindSegueIdentifier" sender:self];

    [self.spinner removeFromSuperview];
    self.spinner = nil;
});

.....并且运行时没有任何反应。精简器确实被正确删除,但没有迹象表明该unwind segue正在执行。

.....and nothing happens when it runs. The spinner does get removed correctly, but there's no sign of that unwind segue executing.

执行 unwindSegue:永远不会被击中。没有错误抛出。什么都没有写入控制台。标识符是正确的,我三重检查(否则它将失败)。

A break point in the implementation of unwindSegue: never gets hit. There are no errors thrown. Nothing gets written to the console. The identifier is correct, I triple checked (otherwise it will fail anyway).

我看了答案这里此处但是我似乎没有错过任何东西。

I looked at the answers here, here and here but I don't seem to have missed anything.

我注意到的是,Xcode认为 unwindSegue:链接:

What I did notice though, is that Xcode thinks unwindSegue: is not linked:

我无法从 unwindSegue:前面的小空圈拖出来,并将其链接到退出按钮。

I'm unable to drag from the little empty circle in front of unwindSegue: and link it to the Exit button.

任何帮助都将不胜感激。

Any help will be appreciated.

推荐答案

如果您使用模态只需转到您的登录视图即可回去就是打电话

If you are using a modal segue to go to your login view, all you need to go back is to call

[self dismissViewControllerAnimated:YES completion:nil];

更确切地说,你应该在演示控制器(你的第一个控制器)上调用它,但它会是如果您在提供的控制器处致电,则转发。您可以使用完成块进行任何所需的清理。没有必要使用GCD。

More precisely, you should call it at the presenting controller (your first controller), but it will be forwarded if you call at at the presented controller. You can use the completion block do any required clean up. There is no need to use GCD.

编辑

回答其他评论:我不太确定从您的描述中可以看出,您似乎已经在呈现的控制器上实现了展开操作,而不是呈现控制器。展开segue允许在没有附加协议的情况下在呼叫者处做某事(例如,设置数据)。

To answer the additional comment: I'm not really sure from your description, but it seems you've implemented the unwind action at the presented controller instead at the presenting controller. Unwind segues are to allow to do something at the caller (e.g., setting data) without an additional protocol.

这篇关于iOS 6 - 以编程方式触发Unwind Segue什么都不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆