我有一个标签视图控制器,它有一个像这样的按钮,当它被按下时,会出现一个模态:
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.