performing programmatic segue after unwind

♀尐吖头ヾ 提交于 2019-12-25 02:28:37

问题


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
}

回答1:


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.



来源:https://stackoverflow.com/questions/21503886/performing-programmatic-segue-after-unwind

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