【发布时间】:2014-01-08 21:24:47
【问题描述】:
做了一个表格视图,它根本没有意义,但我的表格视图隐藏了一些单元格。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 25;
}
- (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:@"Cell"];
}
object= [self.results objectAtIndex:indexPath.row];
cell.textLabel.text=[object valueForKey:@"hLabel"];
return cell;
}
它确实渲染了 25 个单元格,但我最多只能查看 23 个单元格。下面隐藏了 2 个单元格。虽然如果我进一步滚动我可以看到它们,但如果我离开滚动视图会返回,第 23 个是最后一个单元格。因此用户无法选择 24 或 25。
即使我减少单元格数,假设为 23,tableview 仍然隐藏 2 个单元格,并且我无法访问它们,因为滚动在 2 个单元格之前结束。
【问题讨论】:
-
你的视图中除了tableview还有其他对象吗?如果是这样,用代码设置 tableview 框架。高度应该像 (view height-tableview Yaxis)