为已经启动的视图控制器执行带有标识符的 Segue

Perform Segue With Identifier for already Instiated View Controller

我正在尝试使用自定义 segue(在底部)以模态方式呈现具有模糊视图的视图控制器。在呈现视图控制器之前,我需要使用属性实例化视图控制器。

当我使用 pushVC 时,安装 VC 效果很好,但是当我使用 perform segue with identifier 时,我没有看到选择已经实例化的 VC 的选项].

    CustomViewController* VC = [self.navigationController.storyboard instantiateViewControllerWithIdentifier:@"customVC"]; 
    [self.navigationController performSegueWithIdentifier:@"blurSegue" sender:self];

如何执行自定义 segue 并强制它使用我分配的视图控制器(上面称为 VC)?

https://github.com/AlvaroFranco/AFBlurSegue

I need to instantiate the view controller with properties before I present the view controller.

为什么在触发 segue 之前必须实例化 CustomViewController。这应该不是必需的,如果您需要访问 属性 of CustomViewController before 显示,您可以在 prepareForSegue.

中设置

试试这个:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"blurSegue"]) {
        CustomViewController *customViewController = (CustomViewController *)segue.destinationViewController;
        customViewController.propertyToSet = XXX; // set the property here
    }
}

啊,对了,不是

[self.navigationController performSegueWithIdentifier:@"blurSegue" sender:self];

只需使用:

[self performSegueWithIdentifier:@"blurSegue" sender:self];