views:

23

answers:

2

AT certain point in my class ABC, I want to display a UIViewController. ABC itself is not a subclass of UIViewController, hence I cant do

 [self.navigationController pushViewController:myViewController animated:NO]

Is there a way to get a reference to the currently visible UIViewController (top of navigation stack)

A: 

UINavigationController :

@property(nonatomic, readonly, retain) UIViewController *topViewController

The view controller at the top of the navigation stack. (read-only)

@property(nonatomic, readonly, retain) UIViewController *visibleViewController

The view controller associated with the currently visible view in the navigation interface. (read-only)

The currently visible view can belong either to the view controller at the top of the navigation stack or to a view controller that was presented modally.

Benoît
Thanks. But that doesnt solve the problem. I want to access it "statically" from my class ABC, which is simply a NSObject. I have no reference to RootViewController or any other UIViewController. Is there a way to get a reference to a UINavigationController ?
Amarsh
A: 

I solved it by creating a static reference to RootViewController in my AppDelegate and accessing them through static methods.

Amarsh