放松后执行程序化搜索 [英] performing programmatic segue after unwind

查看:87
本文介绍了放松后执行程序化搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个View Controller,V1和V2. V1在情节提要中为V2提供了模态选择.然后,我有一个放松的命令,将V2转到V1.然后调用下面的完成"操作.它会打印出正确的NSLog,但是不会启动[self performSegueWithIdentifier:@"viewmessagessegue" sender:self].当按下V1中的按钮时,我使用同一行代码,并且在这种情况下它可以正常工作.我很困惑为什么它不被称为...

I have two View Controllers, V1 and V2. V1 presents V2 with a modal segue in storyboard. I then have an unwind segue that dismisses V2 to go to V1. The Done action belowed is then called. It prints out the correct NSLog's, however the [self performSegueWithIdentifier:@"viewmessagessegue" sender:self] does not get initiated. I use that same line of code when a button in V1 is pressed, and it works correctly in that scenario. I'm confused as to why it's not being called...

- (IBAction)done:(UIStoryboardSegue *)segue {
    SendToViewController *cc = [segue sourceViewController];
    _users = cc.recipients;
    NSLog(@"users: %@",_users"); // has the correct data
   [self performSegueWithIdentifier:@"viewmessagessegue" sender:self];
    NSLog(@"perform segue...:"); // this gets printed
}

推荐答案

对于这个问题,我不是很肯定,但是我认为当执行"done:"时,实际上并没有在该类中执行(这意味着上一个屏幕的类).它可以在中间位置执行,也可以在调用类中执行(这是您尝试从中展开屏幕的类).如果是这样,它将尝试从展开端而不是从V1端执行prepareForSegue:,因为可能没有segue.identifier,所以它将继续,好像找不到一个....别把这当作福音...我想是在这里,但我可能不会太过分.您可能可以将NSLog放入V2 prepareForSegue:中进行检查.

I'm not positive of the answer on this one, but I think when "done:" is executed, it's really not executed in that class (meaning the class of the previous screen). It's either executing in an in-between place or in the calling class (meaning the class of the screen you are trying to unwind from). If this is true, it will try to execute prepareForSegue: from the unwind side rather than from V1 side and since there probably isn't a segue.identifier, it just continues on as if it didn't find one....Please don't take this as gospel...I'm guessing here, but I may not be too far off the mark. You could probably put a NSLog in the V2 prepareForSegue: to check it.

这篇关于放松后执行程序化搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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