swift获取当前活动的viewcontroller

 var topRootViewController = UIApplication.shared.keyWindow?.rootViewController

 

// 在这里加一个这个样式的循环

 while ((topRootViewController?.presentingViewController) != nil)

 {

          // 这里固定写法

          topRootViewController = topRootViewController?.presentingViewController;

 }

        

posted @ 2020-11-09 09:33  新年新气象  阅读(426)  评论(0编辑  收藏  举报