从 xib 到 xib 的模态转换?

modal segue to a xib from a xib?

我有一个应用程序只使用 xibs,没有故事板。

我创建了一个提示 xib,我想从 table 视图控制器 xib(名为 TVC.xib)以模态方式(使用模态动画)呈现 TVC 嵌套在导航控制器中.

我可以得到提示来展示自己,但我希望它用模态动画来展示自己。不幸的是,presentModalViewController 已被弃用。当前在代码中以模态方式呈现视图控制器并使其以与模态演示用于动画的方式相同的方式进行动画处理的当前选项是什么?

这是我的代码:(在 TVC.m)

PromptViewController *promptVC = [[PromptViewController alloc] initWithNibName:@"PromptXib" bundle:nil];
UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:promptVC];
[self.navigationController presentViewController:navVC animated:YES completion:^{
    NSLog(@"presented prompt vc");
}];

理想情况下,我可以将第 3 行中的方法替换为 self.navigationController presentMODALViewController... 等,但它已被弃用。

您正在寻找:

[self presentViewController:aViewController animated:animated completion:^{}];

但是你应该浏览一些教程来更新知识。

我已经弄明白了。我需要在要显示的视图控制器上设置过渡样式和呈现样式。这是我的解决方案:

PromptViewController *promptVC = [[PromptViewController alloc] initWithNibName:@"PromptXib" bundle:nil];
promptVC.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
promptVC.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:promptVC animated:YES completion:nil];