编译错误从应用程序委托获取导航控制器
在我的 AppDelegate didFinishLaunchingWithOptions 中,我初始化了 UINavigationController
TodoTaskTableViewController *tttvc = [[TodoTaskTableViewController alloc] initInManagedObjectContext:self.managedObjectContext];
UINavigationController *navcon = [[UINavigationController alloc] init];
[navcon pushViewController:tttvc animated:NO];
[window addSubview:navcon.view];
[navcon release];
[window makeKeyAndVisible];
然后在我的 TodoTaskTableViewController 中,我单击推动另一个模态视图的按钮,发现模态视图的导航栏隐藏在 AppDelegate 的导航栏下方。
因此,我尝试通过如下设置来隐藏 AppDelegate 的导航栏:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.navigationController setNavigationBarHidden:YES animated:YES];
但实际上我收到了编译错误:请求成员“navigationController”,而不是结构或联合”
知道如何解决此问题吗?
In my AppDelegate didFinishLaunchingWithOptions, i initialized the UINavigationController
TodoTaskTableViewController *tttvc = [[TodoTaskTableViewController alloc] initInManagedObjectContext:self.managedObjectContext];
UINavigationController *navcon = [[UINavigationController alloc] init];
[navcon pushViewController:tttvc animated:NO];
[window addSubview:navcon.view];
[navcon release];
[window makeKeyAndVisible];
Then at my TodoTaskTableViewController i click on a button which push another modal view, and found that navigation bar of the modal view gets hidden below the AppDelegate's navigation bar.
So i try to hide the AppDelegate's navigation bar by setting it like:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.navigationController setNavigationBarHidden:YES animated:YES];
but i actually get a compile error : Request for member "navigationController" in something not a structure or union"
Any idea how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要向应用委托添加一个名为
navigationController
的属性,然后将其设置为navcon
。在 AppDelegate didFinishLaunchingWithOptions 中:
You need to add a property called
navigationController
to your app delegate, and then set it tonavcon
.In AppDelegate didFinishLaunchingWithOptions: