【问题标题】:UIStoryboardSegue - performSegue method passing the class rather than identifierUIStoryboardSegue - performSegue 方法传递类而不是标识符
【发布时间】:2013-03-22 10:12:04
【问题描述】:

我正在尝试以编程方式执行 segue(因为显然 segue 操作和 IB 操作不能很好地协同工作)。因此,我设置了一个 IBAction 来做一些事情,然后发送 performSegue 方法。我能找到的唯一 performSegue* 方法是“performSegueWithIdentifier:”,这不是我需要的,因为我有一个自定义 segue,它是 UIStoryboardSegue 的子类。

有没有办法以编程方式将类作为 segue 传递(例如在 IB 中,您可以将类设置为 segue 而不是标识符)?

【问题讨论】:

  • 你是什么意思“通过一个类作为一个segue”?

标签: ios xcode interface-builder storyboard


【解决方案1】:

您可以通过手动触发转场来实现这一点。选择文件所有者并为手动触发的 segue 提供标识符。然后你也可以在prepare for segue方法中传递任何你喜欢的东西。

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"ChooseAPlayer"]) {
        chooseplayer = [segue destinationViewController];
        chooseplayer.serviceReceiver = ForNextScreen;
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-15
    • 2018-10-27
    • 1970-01-01
    • 1970-01-01
    • 2019-06-29
    • 1970-01-01
    • 2020-12-22
    相关资源
    最近更新 更多