我的AppDelegate函数didFinishLaunchingWithOptions
我使用SnapSwipeView https://github.com/jakespracher/Snapchat-Swipe-View来控制我的相机'我的AppDelegate
中的ViewControler和if语句,以了解用户是否已登录Parse。
所以这是我的功能:
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var initialViewController: UIViewController
let left = storyboard.instantiateViewController(withIdentifier: "left")
let middle = storyboard.instantiateViewController(withIdentifier: "Camera")
let right = storyboard.instantiateViewController(withIdentifier: "right")
let top = storyboard.instantiateViewController(withIdentifier: "top")
let bottom = storyboard.instantiateViewController(withIdentifier: "bottom")
let snapContainer = SnapContainerViewController.containerViewWith(left,
middleVC: middle,
rightVC: right,
topVC: top,
bottomVC: bottom)
self.window?.rootViewController = snapContainer
如果我只运行此rootViewController=snapContainer
,,但是如果我添加此if语句,哪个工作正常:
if let user = user {
print("logged")
initialViewController = storyboard.instantiateViewController(withIdentifier: "Camera") as! UIViewController
} else {
print("not logged")
initialViewController = storyboard.instantiateViewController(withIdentifier: "IntroMain") as! VideoSplashViewController
}
self.window?.rootViewController = initialViewController
})
如果我的用户没有被记录,它会正确地转到我的IntroMain,但是一旦记录/注册,snapContainer就不能正常工作,因为它还没有已作为rootViewController启动
任何人都知道如何解决这个问题?
非常感谢,