【发布时间】:2012-01-06 14:57:59
【问题描述】:
我有一个 MainWindow.xib 文件:
在里面我定义了一个 UINavigationController 作为 Window 的 rootViewController。 UINavigationController 有一个 TableVC - 项。
TableVC 继承自 UITableViewController 并实现相应的 Delegate 和 Datasource。
我覆盖了4个方法,viewDidload来初始化数据和:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return [data count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
cell.textLabel.text = [data objectAtIndex:indexPath.row];
return cell;
}
我不认为这有什么问题。
当我运行项目时,会出现 NavigationBar 和 TableView 内部,其中填充了我的数据。但是我不能滚动表格!?
感谢任何提示。
【问题讨论】:
-
请问您为什么喜欢将数据显示为每一行的单独部分,而不是单独的一个部分?
-
表格视图是如何添加到导航控制器的?
标签: iphone objective-c uitableview ios4