In my app I am just using typical UIViewController methods to switch views. I am NOT using a UINavigationController. However, I really need to use the visibleViewController API that UINavigationController has.
No I cannot convert my project to using UINavigationController either. Is there any way to check if another UIViewController in my app is the controller that is currently visible?
I switch views using addSubview, and the hidden property right now. (I know this is not a proper way to switch views).
Anyway, in my situation, is it possible to do something similar to visibleViewController?
Thanks!
If you use addSubview:, there's only way to determine the top view in the view hierarchy. You can determine the top view by explore the subviews array property of the root view
UIView *topview = [[rootview subviews] lastObject];
If you want to get something similar to visibleViewController, you should store a map that keep the relationships between an UIView and an UIViewController. So you can get the visibleViewController by geting the topview firstly, then geting the corresponding view controller.
Good luck!