ios – 在显示模态视图控制器后推送导航控制器

前端之家收集整理的这篇文章主要介绍了ios – 在显示模态视图控制器后推送导航控制器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个标签视图控制器,它有一个像这样的按钮,当它被按下时,会出现一个模态:
PostViewController *post = [[PostViewController alloc] init];

// [self.navigationController pushViewController:post animated:YES];

// Presentation
[self presentViewController:post animated:YES completion:nil];

当模态完成后,我想解除它并推送一个新的视图控制器,如下所示:

ProfilesViewController *profile = [[ProfilesViewController alloc] init];
[self.navigationController pushViewController:profile animated:YES];

但我不能在后vc作为它的模态.我该怎么做呢?

解决方法

您可以尝试使用completionBlock.

当presentViewController完成时调用CompletionBlock.

PostViewController *post = [[PostViewController alloc] init];
[con presentViewController:post animated:YES completion:^{
    ProfilesViewController *profile = [[ProfilesViewController alloc] init];
    [self.navigationController pushViewController:profile animated:YES];
}];

有关presentViewController的更多信息:animated:completion:Apple Doc

completion : The block to execute after the presentation finishes. This block has no return value and takes no parameters. You may specify nil for this parameter.

猜你在找的iOS相关文章