Presenting a specific view controller from AppDelegate

前端 未结 4 1358
时光说笑
时光说笑 2021-01-05 02:50

I am trying to present a view controller (a passcode request type view) every time my app becomes active. Once the correct passcode is entered, it should pop off the stack.

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-05 03:37

    Swift version of Quick and generalised way:

    getRootViewController().presentViewController(messageVC, animated: true, completion: nil)
    
    func getRootViewController() -> UIViewController
    {
        return (UIApplication.sharedApplication().delegate?.window??.rootViewController)!
    }
    

提交回复
热议问题