iPhone - topViewController和其他表单之间的区别 [英] iPhone - difference between topViewController and other forms
问题描述
我正在使用基于NavigationControl的应用程序的代理。
当我尝试使用
<时访问rootViewController pre>
RootViewController * rootViewController =(RootViewController *)[navigationController topViewController];
运行一个方法,崩溃,说rootViewController上的方法是未知。
当我使用此访问rootViewController时
RootViewController * rootViewController =(RootViewController) *)[navigationController.viewControllers objectAtIndex:0];
它有效。
哪一个对象是第一行访问?
谢谢
导航控制器的topViewController
表示堆栈顶部的视图控制器。索引 0
是底部。 topViewController
只有当一个视图控制器在堆栈上时才是索引 0
的对象。如果你有多个,那就不一样了。我猜这是因为它崩溃,因为 topViewController
不知道如何响应用于 RootViewController的消息
实例。
I am on a delegate of a NavigationControl based app.
when I try to access the rootViewController using
RootViewController *rootViewController = (RootViewController *)[navigationController topViewController];
to run a method, it crashes, saying the method is "unknown" on the rootViewController.
When I access the rootViewController using this
RootViewController *rootViewController = (RootViewController *)[navigationController.viewControllers objectAtIndex:0];
it works.
Which object is the first line accessing?
thanks
topViewController
of a navigation controller represents the view controller at the top of the stack. Index 0
is the bottom. topViewController
is the object at index 0
only when one view controller is on the stack. If you have more than one, it is not the same. I am guessing that it is the case as it's crashing because the topViewController
doesn't know how to respond to messages intended for a RootViewController
instance.
这篇关于iPhone - topViewController和其他表单之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!