gpt4 book ai didi

ios - 进行模态转场时出现错误的presentingViewController(使用ECSlidingViewController)

转载 作者:行者123 更新时间:2023-11-29 03:53:59 26 4
gpt4 key购买 nike

我从登录 View Controller 中以模态方式呈现注册 View Controller 。我的初始 View Controller 是登录 View Controller ,当我以模态方式呈现注册 View Controller 时,没有任何问题,但是当我使用 ECSlidingViewController 在注销时重置顶部 View 时,出现了问题。我使用以下代码在注销时重置顶 View 以登录 View Controller 。

UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Login"];
[self.slidingViewController anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{
self.slidingViewController.topViewController = newTopViewController;

[self.slidingViewController resetTopView];

}];

当我在使用 ECSlidingViewController 重置顶 View 后以模态方式呈现注册 View 时,注册 View Controller 的presentingViewController 属性将设置为另一个 View Controller ,而不是登录 View Controller 。

我知道很难理解这个问题的本质,但是如果有人需要更多细节来回答这个问题,请随意:)

最佳答案

ECSlidingViewController 似乎确实与 presentingViewController 混淆。

ECSlidingViewController 具有属性 topViewController,您应该能够从那里访问您期望presentingViewController 的 View Controller 。

我能够访问您希望presentingViewController的 View Controller ,如下所示:

ECSlidingViewController *ec = (ECSlidingViewController*)self.presentingViewController;
if(ec) {
UINavigationController *navController = (UINavigationController*)ec.topViewController;

if(navController && navController.viewControllers.count) {

UIViewController *top = navController.viewControllers[0];

// now you'll need to cast top to your presenting view controller's class, eg:
MyViewController *myVc = (MyViewController*)top;
[myVc doSomething];
}
}

您可能没有在应用程序中使用导航 Controller ,在这种情况下,它会是这样的(未经测试):

ECSlidingViewController *ec = (ECSlidingViewController*)self.presentingViewController;
if(ec) {
UIViewController *top = (UIViewController*)ec.topViewController;

if(vc) {
// now you'll need to cast top to your presenting view controller's class, eg:
MyViewController *myVc = (MyViewController*)top;
[myVc doSomething];
}
}

关于ios - 进行模态转场时出现错误的presentingViewController(使用ECSlidingViewController),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16732269/

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