访问navcontroller iPhone的rootviewController时出现问题 [英] Problems accessing rootviewController of navcontroller iphone

查看:37
本文介绍了访问navcontroller iPhone的rootviewController时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究地震xml iphone示例.在该示例中,仅存在一个应用程序委托,该委托具有一个类型为UITableViewController的rootViewController.

Im working off the seismic xml iphone example. In that example there is simply the application delegate which has a rootViewController of type UITableViewController.

我想稍作修改,以便有一个navigationController并将其rootViewController用作表视图.我的导航控制器的根视图控制器类名为"firstLevelViewController"

I wanted to modify it slightly so that I would have a navigationController and use its rootViewController as the table view. My root view controller class for my navigation controller is named "firstLevelViewController"

在示例代码中说

 [rootViewController.tableView reloadData];

我想说的是 [navController.firstLevelViewController.tableView reloadData]

但是我收到错误消息:在某些情况下,对成员firstLevelViewController的请求不是结构或联合"

but I get errors saying "request for member firstLevelViewController in something is not a structure or union"

如何从主应用程序委托中引用navigationcontroller的rootViewController?

How can I reference the rootViewController of the navigationcontroller from the main app delegate?

推荐答案

UINavigationController 中没有 firstLevelViewController 属性.如果要访问当前控制器,可以使用

There isn't a firstLevelViewController property in a UINavigationController. If you want to access the current controller you can use

UITableViewController* firstLevelViewController = navController.topViewController;
assert([firstLevelViewController isKindOfClass:[UITableViewController class]]);
[firstLevelViewController.tableView reloadData];

如果 firstLevelViewController 表示您可以使用底部的视图控制器

If firstLevelViewController means the view controller at the bottom you can use

UITableViewController* firstLevelViewController = [navController.viewControllers objectAtIndex:0];
....

这篇关于访问navcontroller iPhone的rootviewController时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆