我在引用另一个视图控制器时遇到了问题。代码的作品,但我得到警告,这让我觉得我错了。我试图重新加载tableView
中的数据,其controller
位于NavigationController
。
有什么不对这样的消息:正确地遍历ViewController层次结构?
从AppDelegate中:
[self.tabBarController.selectedViewController.topViewController.tableView reloadData];
虽然这工作,我得到警告request for member 'topViewController' in something not a structure or union
因为Xcode的不知道selectedViewController
将返回navigationController
。所以,我可以做到以下几点:
但后来我得到这样的警告:incompatible Objective-C types initializing 'struct UIViewController *', expected 'struct UINavigationController *'
我有多远一起去吗?第一行工作。为了达到“正确的方式”,需要8行代码?
我明白了你的观点。启动此操作的事件是通过`application:handleOpenURL`从另一个应用程序传递给应用程序的文件。如果我决定在我的`tableViewController`中调用一个方法来让它处理这个动作(这听起来像个好主意)。我仍然需要从AppDelegate引用`tableViewController`一次。我经常遇到这种困境,而不仅仅是关于这个问题。看起来我不断将一个对象存储为另一个对象的属性,直到它只是一个蜘蛛网。这就是为什么我在尝试第一行代码,以避免这种情况。 – Andrew 2010-11-27 07:49:36