uitableview从滚动中隐藏2个单元格 [英] uitableview hiding 2 cells from scroll
问题描述
制作了一个表视图,它完全没有意义,但我的表视图隐藏了一些单元格。
made a table view, and it does not make sense at all but my table view is hiding some cells.
- (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个单元格之前。
It does render 25 cells but I am only able to view up to 23. 2 cells are hidden below. Though if I scroll further I can see them but if I leave the scroll the view comes back, 23rd being the last cell. Hence user is not able to select either 24 or 25.
Even if I reduce the cell count, lets say to 23, still the tableview is hiding 2 cells and I am not able to access them as the scroll ends at 2 cells prior.
推荐答案
我遇到了类似的问题,我不知道如何,但当我取消选中Autolayout时,问题得到解决。尝试关闭Autolayout。我希望它对你也有帮助。
I faced a similar issue and i don't know how but when i unchecked Autolayout, the issue gets resolved. Try turning off Autolayout. i hope it helps you too.
这篇关于uitableview从滚动中隐藏2个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!