如何从 UITabBarController 启动的控制器链接模态视图

发布于 2024-10-22 18:08:03 字数 581 浏览 1 评论 0原文

我将如何从 UITabBarController 的视图链接多个模式控制器? Apple 的视图编程指南说这是可行的,但是当我尝试这样的任务时,我收到错误,

"*Assertion failure in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UIWindowController.m:186

类层次结构是这样的:

UITabBarController -> 1 个子级是一个名为 Tab1Controller 的 UIViewController 继承类。

Tab1控制器->编排需要以模态方式呈现的 2 个控制器中的每一个。 启动 1 个模态 UIViewController,当完成时(通过回调调用),将其关闭,然后启动另一个模态 UIViewController。

就好像两个模态控制器结束和开始之间没有足够的时间。

是否有任何示例代码显示如何链接一个又一个模态控制器?

How would I go about chaining several modal controllers from a UITabBarController's view? The View Programming Guide from Apple says this is feasible but when I attempt such a task, I get the error,

"*Assertion failure in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UIWindowController.m:186

The Class hierarchy is something like this:

UITabBarController -> 1 child is a UIViewController inherited class named, Tab1Controller.

Tab1Controller -> orchestrates each of the 2 controllers that need to be presented modally.
Launches 1 modal UIViewController and when this finishes up (get called via a callback), dismisses it and then initiates another modal UIViewController.

It's as if there's not enough time between the two modal controllers ending and starting.

Is there any sample code that shows how to have one modal controller after another can be chained?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

海之角 2024-10-29 18:08:03

请参阅我对此问题的回答:

显示连续模态视图的正确方式

See my answer to this SO question:

Correct way of showing consecutive modalViews

橘香 2024-10-29 18:08:03

就好像两个模态控制器结束和开始之间没有足够的时间。

我认为你说到点子上了。在前一个模态视图控制器完全消失并且在被旧模态视图覆盖的视图控制器上调用 viewDidAppear: 方法之前,您无法呈现新的模态视图控制器。

另一种选择是在第一个模态视图之上呈现第二个模态视图,例如,

[firstModalViewController presentModalViewController:secondModalViewController animated:YES]

您可以调用 [firstModalViewController DismissModalViewControllerAnimated:YES] 来关闭第二个模态视图(返回到第一个),或者 [ selfmissModalViewControllerAnimated:YES] 一次关闭两者。

It's as if there's not enough time between the two modal controllers ending and starting.

I think you've hit the nail on the head there. You cannot present a new modal view controller until the previous one has finished disappearing and the viewDidAppear: method is called on the view controller that had been being covered by the old modal view.

Another option would be to present the second modal view on top of the first, e.g.

[firstModalViewController presentModalViewController:secondModalViewController animated:YES]

You can then call [firstModalViewController dismissModalViewControllerAnimated:YES] to dismiss the second (returning to the first), or [self dismissModalViewControllerAnimated:YES] to dismiss both at once.

情泪▽动烟 2024-10-29 18:08:03
// present modal view inside another presented modal view

    FirstViewController *firstVC = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController: firstVC];

    // Note: you can use your viewcontroller instead self.window.rootViewController

    [self.window.rootViewController presentViewController:navController animated:YES completion:^{
                //code...
                    SecondViewController *secondVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

                    [navController presentViewController: secondVC animated:YES completion:nil];

                }
            }];
// present modal view inside another presented modal view

    FirstViewController *firstVC = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController: firstVC];

    // Note: you can use your viewcontroller instead self.window.rootViewController

    [self.window.rootViewController presentViewController:navController animated:YES completion:^{
                //code...
                    SecondViewController *secondVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

                    [navController presentViewController: secondVC animated:YES completion:nil];

                }
            }];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文