gpt4 book ai didi

ios - PresentViewController dismiss 不会返回到之前的 viewController

转载 作者:行者123 更新时间:2023-11-29 11:37:46 25 4
gpt4 key购买 nike

在我的项目中,我们有三个窗口 A、B 和 C。我想从 A 推送 View B,从 B 我想呈现 View C。我的代码: View Controller A:

ViewControllerB *vcB = [[viewControllerB alloc] 
initWithNibName:@"ViewControllerB" bundle:nil];
[[self navigationController] pushViewController:vcB animated:YES];

View Controller B:

ViewControllerC *vcC = [[ViewControllerC alloc] 
initWithNibName:@"ViewControllerC" bundle:nil];
[self presentViewController:vcC animated: true completion: nil];

到现在为止一切正常,但是当我关闭最后一个 View Controller 时:

[[self presentingViewController] dismissViewControllerAnimated:NO completion:nil];

应用返回到第一个 View Controller (vcA) 而不是第二个 (vcB)

我做错了什么?谢谢你们。

最佳答案

您一定在做其他您没有告诉我们的事情...

这按预期工作:

MyFirstViewController.m

- (IBAction)pushTapped:(id)sender {
MyPushedViewController *vc = [[MyPushedViewController alloc] initWithNibName:@"MyPushedViewController" bundle:nil];
[self.navigationController pushViewController:vc animated:YES];
}

MyPushedViewController.m

- (IBAction)presentTapped:(id)sender {
MyPresentedViewController *vc = [[MyPresentedViewController alloc] initWithNibName:@"MyPresentedViewController" bundle:nil];
[self presentViewController:vc animated:YES completion:nil];
}

MyPresentedViewController.m

- (IBAction)dismissTapped:(id)sender {
[self dismissViewControllerAnimated:NO completion:nil];
}

点击 MyPresentedViewController 中的“关闭”按钮关闭呈现的 View Controller (您的 vcC),让我留在 MyPushedViewController(您的 vcB) ... NOTMyFirstViewController(您的 vcA)。

关于ios - PresentViewController dismiss 不会返回到之前的 viewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48174307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com