【发布时间】:2016-02-13 16:52:44
【问题描述】:
我正在根据 Google 帐户对我的应用进行授权。我有一个包含以下代码的设置视图:
import UIKit
import Google
class Settings: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let background = CAGradientLayer().greenBlue()
background.frame = self.view.bounds
self.view.layer.insertSublayer(background, atIndex: 0)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func didTapSignOut(sender: AnyObject) {
GIDSignIn.sharedInstance().signOut()
}
}
在 gui 中我有一个按钮。当用户单击它时,会话会被此调用破坏:GIDSignIn.sharedInstance().signOut()。但是,到目前为止,没有其他任何事情发生,用户仍在设置菜单中。我想将他转移到包含登录表单的 ViewController 中。
我尝试添加以下代码:
let sb = UIStoryboard(name: "Main", bundle: nil)
if let tabBarVC = sb.instantiateViewControllerWithIdentifier("TabController") as? TabController {
window!.rootViewController = tabBarVC
}
但是window 未解决。我该怎么做?
【问题讨论】:
-
请发布您的故事板结构,以便我为您提供帮助。
-
查看我的详细回复,了解为什么 window 对象无法解析。
标签: ios swift google-signin