以编程方式进行调查

时间:2016-04-21 18:17:38

标签: segue

获取获取请求并从核心数据中获取值。基于值F或M,我想要转向VC。它一直在App Delegate上崩溃。我正在使用标签栏控制器来点击进行计算的VC,然后应该转到适当的VC。

func makeSegue() {

    print("\(meetGenderText.text!)")

    if (meetGenderText.text == "F") {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)

        let vc = storyboard.instantiateViewControllerWithIdentifier("scoreFemale") as! ScoreMeetFemaleVC

        presentViewController(vc, animated: true, completion: nil)

        performSegueWithIdentifier("scoreFemale", sender: nil)

    } else {

        let storyboard = UIStoryboard(name: "Main", bundle: nil)

        let vc = storyboard.instantiateViewControllerWithIdentifier("scoreMale") as! ScoreMeetFemaleVC

        presentViewController(vc, animated: true, completion: nil)

        performSegueWithIdentifier("scoreMale", sender: nil)
    }
}

1 个答案:

答案 0 :(得分:0)

您不应同时使用presentViewControllerperformSegueWithIdentifier。如果您想使用performSegueWithIdentifier,请确保故事板中存在segue,并从您UIViewController调用的performSegueWithIdentifier开始。还要确保代码中的标识符与storyboard中的segues标识符匹配。