swift - Content under a login View is visible for a fraction of second -
i have view displaying content, password protected. in viewwillappear
variable gets checked, see if user logged in :
override func viewwillappear(animated: bool) { if (!config.userloggedin) { let storyboard = uistoryboard(name: "main", bundle: nil) let loginvc = storyboard.instantiateviewcontrollerwithidentifier("loginvc") as! uiviewcontroller loginvc.modaltransitionstyle = uimodaltransitionstyle.crossdissolve self.navigationcontroller!.presentviewcontroller(loginvc ,animated: true, completion: nil) } }
it works, content underneath visible short fraction of second. how can present loginvc without revealing content underneath. cannot put in viewdidload
because part of tabbarcontroller, , views might in memory , viewdidload
called once
simple solution. hide whole view in viewdidload show in viewviewappear if user correctly logged in
override func viewdidload(){ self.view.hidden = true } override func viewwillappear(animated: bool) { if (!config.userloggedin) { let storyboard = uistoryboard(name: "main", bundle: nil) let loginvc = storyboard.instantiateviewcontrollerwithidentifier("loginvc") as! uiviewcontroller loginvc.modaltransitionstyle = uimodaltransitionstyle.crossdissolve self.navigationcontroller!.presentviewcontroller(loginvc ,animated: true, completion: nil) }else{ self.view.hidden = false } }
Comments
Post a Comment