我无法使我的入门系统正常工作。我正在使用这个框架:
https://github.com/mamaral/Onboard

该框架的演示仅在Objective-C中提供,我已经尽力在Swift中创建自己的版本,并且几乎完成了,但是在最后一屏之后,我陷入了转移到另一个故事板的方法中。这是我目前的代码:

class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

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


    func setupNormalRootViewController() -> Void {

        self.window?.rootViewController = LoginViewController

    }


    let firstPage = OnboardingContentViewController(title: "Welcome To my App", body: "App Mesage", image: UIImage(named: "heart"), buttonText: "") {}
    let secondPage = OnboardingContentViewController(title: "...", body: "Message", image: UIImage(named: "Mint"), buttonText: "") {}

    let thirdPage = OnboardingContentViewController(title: "title", body: "abcd", image: UIImage(named: "Choco"), buttonText: "End", action: { setupNormalRootViewController() } ) {}

    let onboardingVC = OnboardingViewController(backgroundImage: UIImage(named: "blueBackground"), contents: [firstPage, secondPage,thirdPage])




    self.window?.rootViewController = onboardingVC
 }
}


我正在setupNormalRootViewController变量中调用thirdPage,但即使按了最后一个屏幕上的按钮时,我已设置了要运行的指定方法,似乎也无法继续前进。

最佳答案

    class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?



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




    let firstPage = OnboardingContentViewController(title: "Welcome To my App", body: "App Mesage", image: UIImage(named: "heart"), buttonText: "") {}
    let secondPage = OnboardingContentViewController(title: "...", body: "Message", image: UIImage(named: "Mint"), buttonText: "") {}

    let thirdPage = OnboardingContentViewController(title: "title", body: "abcd", image: UIImage(named: "Choco"), buttonText: "End") { () -> Void in
        self.setupNormalRootViewController()
    }

    let onboardingVC = OnboardingViewController(backgroundImage: UIImage(named: "blueBackground"), contents: [firstPage, secondPage,thirdPage])


    self.window?.rootViewController = onboardingVC


    return true
}

func setupNormalRootViewController() -> Void {

    self.window?.rootViewController = ViewController()

}
}

关于ios - Swift中的Mamaral入门库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38042710/

10-11 14:42