gpt4 book ai didi

ios - 如何关闭模态视图 Controller ,然后立即让呈现 View Controller 呈现不同的模态视图 Controller ?

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

我正在使用 IIViewDeckController作为我的 Root View Controller 。它是一个库,允许我拥有一个类似于 facebook 应用程序中的滑动菜单的滑动菜单 View Controller 。它的工作原理是使用中心和左侧 View Controller 启动它,然后将整个事物设置为 Root View Controller 。这是 AppDelegate.m 中的样子:

FeedViewController* mainFeed = [[FeedViewController alloc] init];
UINavigationController* mainStack = [[UINavigationController alloc] initWithRootViewController:mainFeed];

MenuViewController* sideMenu = [[MenuViewController alloc] init];

IIViewDeckController* viewDeck = [[IIViewDeckController alloc] initWithCenterViewController:mainStack leftViewController:sideMenu];

self.window.rootViewController = viewDeck;

当在中心 View Controller ( navStack ) 中时,我有一个按钮,按下时会显示一个模态视图 Controller login :

- (void)openLogin{
LoginViewController* login = [[LoginViewController alloc] init];
[self presentViewController:login animated:YES completion:nil];
}

login ,在用户输入他们的凭据并登录后,我尝试让 navStack解雇login ,然后立即插入另一个 Controller creator :

- (void)dismissLoginController{
//get a reference to the mainFeed
IIViewDeckController* viewDeck = (IIViewDeckController*)self.presentingViewController;
UINavigationController* navStack = (UINavigationController*)viewDeck.centerController;
FeedViewController* mainFeed = (FeedViewController*)navStack.topViewController;

//have it dismiss login, then push creator
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
[mainFeed openListingCreator];
}

openListingCreatormainFeed :

- (void)openListingCreator{
ListingCreatorViewController* creator = [[ListingCreatorViewController alloc] init];
UINavigationController* creationStack = [[UINavigationController alloc] initWithRootViewController:creator];
[self presentViewController:creationStack animated:YES completion:nil];
}

我得到的错误是:Warning: Attempt to present <UINavigationController: 0xa40c790> on <IIViewDeckController: 0xa843000> whose view is not in the window hierarchy!

我假设这是因为当我要求它显示 View Controller 时 IIViewDeckController 不在屏幕上。然而openListingCreator在我关闭 login 之后被调用 View Controller ,所以我不确定为什么要这样做。我相信它与 IIViewDeckController 有关,因为我之前在没有它的其他项目中完成过同样的过程并且没有任何问题。

有什么想法吗?

最佳答案

您收到此错误是因为 openListingCreatorLoginViewController 的过渡效果仍处于事件状态时被调用。您可以将 [mainFeed openListingCreator]; 放在 [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; 的完成 block 中或呈现 creationStack直接来自 LoginViewController

[self.presentingViewController dismissViewControllerAnimated:YES completion:^{
[mainFeed openListingCreator];
}];

关于ios - 如何关闭模态视图 Controller ,然后立即让呈现 View Controller 呈现不同的模态视图 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21081377/

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