首页 > 技术文章 > swift获取当前活动的viewcontroller

hualuoshuijia 2020-11-09 09:33 原文

 var topRootViewController = UIApplication.shared.keyWindow?.rootViewController

 

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

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

 {

          // 这里固定写法

          topRootViewController = topRootViewController?.presentingViewController;

 }

        

推荐阅读