How to get visible viewController from app delegate when using storyboard?

后端 未结 14 1690
小蘑菇
小蘑菇 2020-12-05 00:14

I have some viewControllers, and I don\'t use NavigationController. How can I get visible view controller in app delegate methods (e.g. appli

14条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 00:48

    If you are using IQKeyboardManager they have an extension in there

    • (UIViewController*)currentViewController;

    so you can do

     application.keyWindow?.currentViewController? // <- there you go
    

    so add this to your pod file

    pod 'IQKeyboardManager'
    
    then pod update and you are away!
    

    hope this helps

提交回复
热议问题