【发布时间】:2010-12-05 02:00:00
【问题描述】:
我现在很难让导航栏正常工作。以下是我的层次结构。
TabBarController
-- NavigationController
-- View
-- Navigation Controller
-- View
-- Navigation Controller
-- View
我为每个标签栏视图继承了一个抽象类。此抽象类设置为 NavigationBar 委托,并具有导航栏 iboutlet。
在我的一个视图中,我设置了一个表格视图,当有人选择表格视图时,我希望它转到更详细的视图。以下是我用来执行此操作的代码。当我设置 xib 时,我将 NavigationBar 拖到视图上,然后将“VisitedPlace”的 ViewController 设置为导航栏的委托。
// Called when a row in the table view has been selected.
// This method will change the view to the current place detailed view
- (void) tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *) indexPath {
NSLog(@"We are here, and proud of it I suppose~");
PlaceViewController *placeView = [[PlaceViewController alloc] initWithNibName:@"PlaceView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:placeView animated:YES];
[placeView release];
placeView = nil;
}
当我选择该行时,会打印日志消息,但没有任何反应。
我现在很迷茫,我一定错过了一些关键的东西。我正在阅读有关 NavigationController 以及如何实现它的信息,但老实说,我不知道该怎么做。
编辑: 当我 NSLog'd self.navigationController 它是 nil 时,我拖了一个 NavigatonController 并将 Delegate 设置为 VisitedPlaces 的文件所有者。但是,导航控制器仍然为零。
任何帮助将不胜感激!
【问题讨论】:
-
验证 self.navigationController 不是 nil
-
它是零。我已将导航控制器拖入 VisitedPLaces.xib。我希望导航栏在标签栏仍在原位时推送和弹出视图。
-
我实际上发现了我做错了什么,我看了 Orielly 的一个非常好的教程,你可以在这里找到它:youtube.com/watch?v=LBnPfAtswgw&feature=player_embedded
标签: iphone objective-c