Get the current view controller from the app delegate

前端 未结 11 1986
悲哀的现实
悲哀的现实 2020-11-30 22:46

i am new to ios. I need to know the current view controller from app delegate.. i have no idea about this and i don\'t knowto implement this. i am using this code toimplemn

11条回答
  •  生来不讨喜
    2020-11-30 23:13

    |*| Get Visible View Controller from Navigation View Controller

    let NavVccVar = UIApplication.sharedApplication().keyWindow?.rootViewController as! UINavigationController
    let ShnSrnVar = NavVccVar.visibleViewController
    

    |*| Presenting from the Visible View Controller

    let NavVccVar = UIApplication.sharedApplication().keyWindow?.rootViewController as! UINavigationController
    NavVccVar.visibleViewController!.presentViewController(NamVccVar, animated: true, completion: nil)
    

提交回复
热议问题