使BWWalkthrough库在启动时启动

时间:2016-09-27 16:37:02

标签: ios xcode swift3 bwwalkthrough

我对BWWalkthrough库有点困惑,我试图在应用程序启动时实现它。我有两个故事板主要一个和SlidesFlow故事板。我将主界面设置为SlidesFlow,并将初始故事板设置为SlidesFlow。我为BWWalkthroughViewController创建了1个视图,为BWWalkthroughPageViewController创建了另外4个视图。在didFinishLaunchingWithOptions函数的AppDelegate中,我使用了以下代码:

private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.

    // Get view controllers and build the walkthrough
    let stb = UIStoryboard(name: "SlidesFlow", bundle: nil)
    let walkthrough = stb.instantiateViewController(withIdentifier: "SlideShow") as! BWWalkthroughViewController
    let page_zero = stb.instantiateViewController(withIdentifier: "Slide_1")
    let page_one = stb.instantiateViewController(withIdentifier: "Slide_2")
    let page_two = stb.instantiateViewController(withIdentifier: "Slide_3")
    let page_three = stb.instantiateViewController(withIdentifier: "Slide_4")

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

    return true
}

这不应该吗?我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

发现问题,似乎didFinishLaunchingWithOptions函数根本没被调用,因为我将我的项目从xcode 7转移到xcode 8.所以如果有人在努力解决类似的问题,只需替换旧的didFinishLaunchingWithOptions功能

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool

用这个:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool