当我从AppDelegate调用函数时,Segue不起作用

时间:2015-10-26 07:00:26

标签: ios swift segue appdelegate

我有一个奇怪的问题。我想从linkedin OAuth登录我的服务器,我做到了。一切正常,但我不能以编程方式运行segue。

这是我在AppDelegate中的代码

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    var username: String?
    var password: String?

    let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let setViewController = mainStoryboard.instantiateViewControllerWithIdentifier("LogInSocial") as! LogInSocialController

    var workingURL = url.absoluteString.componentsSeparatedByString("?")[1]
    workingURL.componentsSeparatedByString("&").map {
        $0.componentsSeparatedByString("=")
        }.reduce([:]) {
            (var dict: [String:String], p) in
            dict[p[0]] = p[1]

            username = dict["username"]
            password = dict["password"]

            return dict
    }

        setViewController.LNCredentials(url, username: username!, password: password!)
    }

所以,当我的应用程序从linkedin webView获得响应时,它会运行上面的功能。在这个功能里面我放了一个

setViewController.LNCredentials(url, username: username!, password: password!)

此功能在我的ViewController中:

func LNCredentials(url: NSURL, username: String, password: String) {
    print("\(username) \(password)")
    self.performSegueWithIdentifier("fromSocialToOpenChats", sender: nil)
}

我在这里登录usernamepassword,但是segue没有执行。

谁能帮我解决这个问题?我不知道为什么它不起作用

0 个答案:

没有答案