iPhone:创建一个基于层次结构的表导航
我试着问过这个,但没有得到任何答案。基本上,我希望有人向我解释如何创建一个表格,当点击一个单元格时,将用户推入该单元格的下一个视图。我有这个至今:iPhone:创建一个基于层次结构的表导航
Click here to view what I have.
我愿进一步,说什么时候CSS被窃听,它进入具有另一个表中有一个新的看法。然后这个表格将用户带到一个可滚动的细节视图,您可以通过它切换页面。
我将不胜感激更长的,更结构化的教程,如何做到每一个点,以得到它工作。
下面是我在我的实现文件数组:
- (void)viewDidLoad {
arryClientSide = [[NSArray alloc] initWithObjects:@"CSS", @"HTML", @"JavaScript", @"XML", nil];
arryServerSide = [[NSArray alloc] initWithObjects:@"Apache", @"PHP", @"SQL", nil];
self.title = @"Select a Language";
[super viewDidLoad];
}
和我的.h:
@interface RootViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
IBOutlet UITableView *tblSimpleTable;
NSArray *arryClientSide;
NSArray *arryServerSide;
}
我当前的代码崩溃的脚本,并在控制台返回此错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "NextView" nib but didn't get a UITableView.'
如果这个错误是它不推动的原因,那么解释如何纠正这个错误LD还可以理解的
NextViewController实施
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
arryBasicCSS = [[NSArray alloc] initWithObjects:@"Implement", @"Syntax", @"Classes and IDs", @"Fonts", @"Backgrounds", @"Lists", @"Links", nil];
arryIntermediateCSS = [[NSArray alloc] initWithObjects:@"Padding and Margin", @"Alignment and Floating", @"Pseudo-class and Element", @"Opacity and Display", nil];
arryAdvancedCSS = [[NSArray alloc] initWithObjects:@"Sprites", @"Attribute Selectors", @"Animation", nil];
self.title = @"CSS";
[super viewDidLoad];
}
- (IBAction) changeItemTable:(NSString *)str{
tblCSS = str;
}
NextViewController.h
@interface NextViewController : UITableViewController {
IBOutlet UITableView *tblCSS;
NSArray *arryBasicCSS;
NSArray *arryIntermediateCSS;
NSArray *arryAdvancedCSS;
}
非常感谢, 杰克
首先, “终止应用程序由于未捕获的异常”错误。我注意到,你的RootViewController的包含:
IBOutlet UITableView *tblSimpleTable;
检查以确保您已正确连接RootViewController的“观点”属性设置为您的UITableView,而不仅仅是连接tblSimpleTable到您的TableView。 UITableViewController中的view属性需要指向一个UITableView。
假设tblSimpleTable是要从此UIViewController控制的TableView,请删除此插座并使用UITableViewController的“view”或“tableView”属性,它们都将是有效的。
对于你原来的分级表视图问题,必须在看看这个示例项目:
如果SDK自己的文档不提供答案您需要尝试谷歌搜索UITableView Interface Builder tutorial
。这应该会返回一些有用的分步教程。
您得到例外的原因是因为您尚未将您的tblSimpleTable
插座连接到Interface Builder中的表格视图对象。
IB Outlets http://i41.tinypic.com/ohr1jb.png
打开NextView.xib在Interface Builder。选择File's Owner
对象。打开检查器窗格,你会看到类似于我发布的图像的东西。你应该阅读“tblSimpleTable”而不是“searchTable”。要将插座连接到文件的所有者,请单击并按住“tblSimpleTable”右侧的圆圈并将该行拖到您的“tblSimpleTable”对象。
alt text http://i44.tinypic.com/2pr8pi0.jpg
保存更改,重新构建项目。
谢谢。我想我陷入了一个混乱的循环:我得到了各地的参考。当我尝试尝试你所做的时,我会遇到这两个错误。顺便说一下,我通过IB手动创建了tblCSS。不知道你的意思是我需要tblSimpleTable。我用我的NextViewController文件中的代码更新了我的帖子。 – 2010-04-24 16:05:34
这将工作分组表吗?另外,如何为表中的每个项目分配一个新的视图? – 2010-04-30 20:23:09