开发者

Instance of the ViewController

I want to access the current ViewController.

I have a TabBar with a NavBar and there is a ViewController in it. In this ViewController (TableView) I made a "pushViewController" to a new ViewController.

How can I access this one in another class. If I do:

[(MyTestDetailViewController *)[[(UINavigationController *) [appDelegate.myTabBarController selectedViewController] viewControllers] objectAtIndex: 0] myMethod:testArg1 withArgs:testArg2];

the method of the first ViewController is calle开发者_运维知识库d (it also have the same myMethod:withArgs in it), but not this one of the current view (the pushed one).

What's wrong here? Does anyone know?

Thanks a lot in advance & Best Regards.


The UINavigationController implements the visibleViewController property for this purpose.

Try this:

[(MyTestDetailViewController *)[(UINavigationController *)[appDelegate.myTabBarController selectedViewController] visibleViewController] myMethod:testArg1 withArgs:testArg2];

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜