gpt4 book ai didi

ios - 应用程序的教程屏幕

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

您好,我找到了一个很棒的教程来展示我的应用程序的概览。查看本教程 View 后,您将如何返回主应用程序?这是教程和所有 source code 的位置.

我的应用程序 View 在 Storyboard 中,我有一个导航 Controller ,其中包含我的 Root View Controller 。我希望在显示教程 View 的最后一页后返回到导航 Controller 的 rootviewcontroller。如果您能提供帮助,谢谢。

enter image description here

这是我的 Storyboard:我用来加载教程的代码在 AppDelegate 中是这样的:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
/* This loads up the xib but I can't get back to the storyboard rootViewController */
if (tutorialHasBeenSeen == false) {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.appViewController = [[APPViewController alloc] initWithNibName:@"APPViewController" bundle:nil];
self.window.rootViewController = self.appViewController;
[self.window makeKeyAndVisible];
tutorialHasBeenSeen =TRUE;

}


return YES;
}

我会尝试在方法中弹出到 AppViewController.m 中的 rootView 吗:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {

NSUInteger index = [(APPChildViewController *)viewController index];

index++;

if (index == 5) {
return nil;
}
return [self viewControllerAtIndex:index];

}

最佳答案

你用过吗

[self.navigationController popToRootViewControllerAnimated:YES];

编辑

既然我看到了您正在尝试做的事情,我建议您改变您的方法:与其选择是否应该在应用程序委托(delegate)的 didFinishLaunchingWithOptions 方法中显示 Tutorial,不如总是从应用程序的 First View Controller 开始,并在此处确定是否用户是否应该显示 Tutorial,这样你就可以在你的 First View Controller 中以你建立的显示分层内容的导航方式调用 Tutorial View Controller 。

enter image description here

您不能从教程 转到您的第一个 View Controller 的原因是因为您将教程 指定为您的窗口 View 直接来自应用程序委托(delegate)的 Controller 。因此,无法从教程返回”到您的第一个 View Controller ,要解决这个问题,我可以考虑两种选择,

  • 在需要的时候将应用程序的窗口 View Controller 更改为您的第一个 View Controller ,而不是已经分配的教程 View Controller 。正如您可能猜到的那样,这是一种棘手且不干净的方法。
  • 在您的应用中设置适当的导航层次结构,因此第一个 View Controller 应该显示您的教程 View Controller 。然后,在所需的时刻,您只需关闭或弹出您的教程并返回到您的第一个 View Controller 。

作为结论,

1.不要从 AppDelegate 中展示您的教程,因此请保持以下方法干净或根据需要执行其他操作。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}

2.从将成为您的第一个 View Controller 的 View Controller 中,使用segues 调用您的教程。或通过 code应用您想要的逻辑来确定用户何时应该看到教程。如果在应用程序启动时正确完成并且出现教程,那么您将首先显示第一个 View Controller

3.从您的教程 View Controller 和在需要的时刻dismisspop (将取决于您的导航)您的 View Controller ,以便您可以返回到第一个 View Controller

关于ios - 应用程序的教程屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20973359/

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