UIViewController *vc = self.window.rootViewController;
Once you know the root view controller, then it depends on how you have built your UI, but you can possibly find out a way to navigate through the controllers hierarchy.
If you want the topmost view (not view controller), you could check
[[[[UIApplication sharedApplication] keyWindow] subviews] lastObject];
although this view might be invisible or even covered by some of its subviews...
again, it depends on your UI, but this might help...
The problem with this is if the visible view does not belong to the root view controller (in the case of modal views and such).
Yes, I do. But it maybe a UITabViewController. Isn't there a directly method to get the UIViewController on the screen?
well, you see, UINavigationController provides a way for you to know which controller is topmost; your root controller should provide the same info some way. It cannot be inferred in general because it depends strictly on how you built your UI and there is no explicit controller hierarchy (like it happens for views). You may simply add a property to your root controller and set its value whenever you "push" a new controller on top.
As long as the value is kept up to date, that seems like a good way to go to me too.
There is no direct way of getting to the controller from a UIView instance. rootViewController is not necessarily the currently shown controller. It's just at the top of the view hierarchy.