1

I have a problem in my AppDelegate function didFinishLaunchingWithOptions

I use the SnapSwipeView https://github.com/jakespracher/Snapchat-Swipe-View to control my 'Camera' ViewControler in my AppDelegate and the if statement to know if the user is already logged in Parse.

So here is my function :

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

Which work fine if I only run this rootViewController=snapContainer, but if I add this if statement :

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
})

If my user isn't logged, it goes correctly to my IntroMain, but once he is logged/signup, the snapContainer isn't working because it hasn't been launched as rootViewController

Anyone knows how I can fix this?

Many thanks,

Salman Ghumsani
  • 3,647
  • 2
  • 21
  • 34
Bonilla
  • 99
  • 2
  • 11
  • How and where are you switching your root view controller after logging in the user? – kerry Jun 14 '17 at 05:32
  • I don't switch for now. – Bonilla Jun 14 '17 at 05:36
  • So where are you moving to snapcontainer after user logs in? – kerry Jun 14 '17 at 05:37
  • That's my problem :) for now I cannot have both working. If i comment the if user statement, my snapcontainer works, and if I comment the snapcontainer rootviewcontroller, my if user statement works – Bonilla Jun 14 '17 at 05:39
  • So there are two ways to solve this. Either you change the root view controller after the user logs in probably in some call back or move to SnapContainer using a segue – kerry Jun 14 '17 at 05:42
  • Thanks kerry for the option but I have tried to change the rootviewcontroller in my Camera Viewcontroller (viewdidload) but it didnt work.. and using a segue doesnt launch correctly all the swipe controller which I have if I use the self.window?.rootViewController = snapContainer – Bonilla Jun 14 '17 at 05:44

0 Answers0