模态从xib到xib?

时间:2015-08-04 17:12:59

标签: objective-c xcode uinavigationcontroller segue xib

我的应用只使用了xib,没有使用故事板。

我创建了一个提示xib,我想从表视图控制器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");
}];

理想情况下,我可以使用self.navigationController presentMODALViewController等替换第3行中的方法,但不推荐使用它。

2 个答案:

答案 0 :(得分:0)

您正在寻找:

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

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

答案 1 :(得分:0)

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

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