开发者

reference to currently visible uiviewcontroller

开发者 https://www.devze.com 2023-01-20 12:59 出处:网络
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

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 ge开发者_JS百科t a reference to the currently visible UIViewController (top of navigation stack)


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消