performSegueWithIdentifier奇怪的行为

时间:2016-05-31 20:17:30

标签: ios swift uistoryboardsegue

我使用BWWalkthrough在我的应用开始时设置了一个演练视图,它运行正常。现在我只是试图跳过该视图,如果用户已经看到它。很简单吧?但不知怎的,它不起作用。这就是我所拥有的:

在我的故事板上,我在BWWalkthroughViewController和我的应用程序的主视图之间设置了一个segue,并称之为“RootView”

这是我的代码:

class TutorialViewController: BWWalkthroughViewController {

    @IBOutlet weak var endTutorialButton: UIButton!

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        // Check if should skip this viewcontroller
        let shouldSkipTutorial = NSUserDefaults().boolForKey(Constants.UserPreferences.TUTORIAL_SEEN_KEY)
        if shouldSkipTutorial {
            // In debugger this part is reached but the segue is not executed
            finishTutorial()
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Here I setup everything walkthrough related

    }

    // This is called when the user reaches the end of the walkthrough and press the finish button. The weird part is, this works fine! walkthrough is dismissed and next ViewController is pushed.
    @IBAction func endTutorial(sender: AnyObject) {
        NSUserDefaults().setBool(true, forKey: Constants.UserPreferences.TUTORIAL_SEEN_KEY)
        finishTutorial()
    }

    func finishTutorial() {
        self.performSegueWithIdentifier("ShowRoot", sender: nil)
    }
}

问题出在哪里?

0 个答案:

没有答案