首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >欢迎屏幕启动

欢迎屏幕启动
EN

Stack Overflow用户
提问于 2015-12-09 19:11:27
回答 1查看 2.2K关注 0票数 3

我想让用户有一个欢迎的屏幕/教程的第一次启动的应用程序。如果这不是该应用程序的第一次发布,那么它就会像往常一样打开。

如果应用程序正常打开,我已经将欢迎屏幕绑定到按钮功能上。我在用BWWalkThroughViewController。下面是按钮函数的代码:

代码语言:javascript
复制
@IBAction func showWalkThroughButtonPressed() {

    // Get view controllers and build the walkthrough
    let stb = UIStoryboard(name: "MainStoryboard", bundle: nil)
    let walkthrough = stb.instantiateViewControllerWithIdentifier("walk0") as! BWWalkthroughViewController
    let page_one = stb.instantiateViewControllerWithIdentifier("walk1") as UIViewController
    let page_two = stb.instantiateViewControllerWithIdentifier("walk2") as UIViewController
    let page_three = stb.instantiateViewControllerWithIdentifier("walk3") as UIViewController
    let page_four = stb.instantiateViewControllerWithIdentifier("walk4") as UIViewController
    let page_five = stb.instantiateViewControllerWithIdentifier("walk5") as UIViewController

    // Attach the pages to the master
    walkthrough.delegate = self
    walkthrough.addViewController(page_one)
    walkthrough.addViewController(page_two)
    walkthrough.addViewController(page_three)
    walkthrough.addViewController(page_four)
    walkthrough.addViewController(page_five)

    self.presentViewController(walkthrough, animated: true, completion: nil)
}

func walkthroughCloseButtonPressed() {
    self.dismissViewControllerAnimated(true, completion: nil)
}

该代码位于MyTableViewController.swift文件中。

,我想不出的是:

我希望视图控制器在第一次发射时显示。一旦用户完成本教程,他们可以按下关闭按钮,它将关闭。我有代码来检查这是否是应用程序的第一次发布。它位于AppDelegate.swift文件中。这是密码:

代码语言:javascript
复制
// First Launch Check

    let notFirstLaunch = NSUserDefaults.standardUserDefaults().boolForKey("FirstLaunch")
    if notFirstLaunch {
        print("First launch, setting NSUserDefault")
        NSUserDefaults.standardUserDefaults().setBool(true, forKey: "FirstLaunch")
    }
    else {
        print("Not first launch.")
    }
    return true

那么,如何让欢迎屏幕在第一次发射时启动呢?我是否必须在AppDelegate中创建一个函数来处理这个问题,如果需要的话,我需要做什么才能使教程成为第一次启动时的初始视图控制器?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-09 21:17:12

我相信您需要做的事情已经在这里讨论过了:Programmatically set the initial view controller using Storyboards。如果这不适用于您,请添加更多说明为什么实现失败的说明。谷歌搜索“在启动ios上以编程方式改变uiviewcontroller”将产生其他类似的链接。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34187067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档