[Objective-C] How to retrieve the current displayed viewcontroller
      back

//
// how to retrieve the current displayed viewcontroller
//
+ (UIViewController*)topMostController
{
    UIViewController *topController = [[UIApplication sharedApplication] keyWindow].rootViewController;
    while (topController.presentedViewController) {
        topController = topController.presentedViewController;
    }
    
    return topController;
}






Copyright © 1996-2020 Centro Studi Informatica di Danilo Priore. All rights reserved. P.I.10149810581.