我试图在swift 3中成功登录时执行segue。一旦我的web服务返回成功消息,我想执行segue。我正在尝试以下方式:
DispatchQueue.main.sync(execute: {
print("Login successful")
self.performSegue(withIdentifier: "goToTimerPage", sender: self)
})
我的日志打印正常。 请帮我解决一下这个。我是网络服务的新手。
答案 0 :(得分:0)
简单的导航方式。
像这样设置didFinishLaunchingWithOptions
。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let storyboard :UIStoryboard
if UIDevice.currentDevice().userInterfaceIdiom == .Pad{
storyboard = UIStoryboard(name: "Main_iPad", bundle: nil)
}
else{
storyboard = UIStoryboard(name: "Main", bundle: nil)
}
let navigationController:UINavigationController = storyboard.instantiateInitialViewController() as! UINavigationController
let objLoginViewController:UIViewController = storyboard.instantiateViewControllerWithIdentifier("ID_LoginViewController") as! LoginViewController
navigationController.viewControllers = [objLoginViewController]
if self.window != nil {
self.window!.rootViewController = navigationController
}
return true
}
获得成功回复后调用此函数。
self.redirectToNewViewcontroller()
redirectToNewViewcontroller函数的代码
func redirectToNewViewcontroller()
{
let objNewViewController = self.storyboard?.instantiateViewControllerWithIdentifier("ID_NewViewController") as? NewViewController
self.navigationController?.pushViewController(objNewViewController!, animated: true)
}
答案 1 :(得分:0)
像这样使用
browserify
答案 2 :(得分:0)
只需确保将视图控制器嵌入导航控制器即可 源视图控制器不是目标视图控制器