6

我有一个标签视图控制器,它有一个像这样的按钮,当它被按下时,会出现一个模式:

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];

但是我不能在 post vc 中将其作为模态。我该怎么做呢?

4

2 回答 2

7

您可以尝试使用completionBlock.

CompletionBlock在 presentViewController 完成时调用。

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的更多信息

完成:演示完成后要执行的块。这个块没有返回值,也没有参数。您可以为此参数指定 nil。

于 2014-10-09T08:15:46.400 回答
1

将您的选项卡视图控制器嵌入 UINavigationController 吗?如果你没有,你当然不能使用 self.navigationController。

于 2014-10-09T08:16:58.607 回答