第一个单元格在表格中始终为空仅显示第二个单元格 - 目标c

时间:2014-01-23 06:04:25

标签: ios objective-c uitableview

我有一个表格视图,显示数组中的联系人。我按照以下方式设置了表视图委托。

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [contactArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *simpleTableIdentifier = @"ContactCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:simpleTableIdentifier];
    }
    cell.textLabel.text = [contactArray objectAtIndex:indexPath.row];
    return cell;

}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60.0;

}

但表格视图中的第一个单元格始终为空。它仅从第二个单元格开始显示。我认为这可能是标题视图。所以我使用以下委托方法删除了标头。

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.0;

}

但仍有问题。我附上了关于这个问题的截图。 screenshot

任何帮助将不胜感激。

3 个答案:

答案 0 :(得分:5)

您的TableView很好,而且工作正常,这是由于iOS 7中包含的其他一些问题,它会自动滚动插入内容。要解决此问题,请转到故事板并选择TableView所在的视图控制器,然后选择ViewController并选择Properties的{​​{1}},并取消选中此复选框,读作ViewController。看这个截图,

enter image description here

答案 1 :(得分:2)

你的桌子是正确的。你的桌子是由viewController自动调整的。 你可以写self.automaticallyAdjustsScrollViewInsets = NO;

答案 2 :(得分:0)

您的扣除错误,您的第一个牢房没有丢失,但您的桌面视图已经开始下降64点。因此,相应地更改tableview的框架或tableview约束。 提示:当您需要调试此类内容时,请尝试设置背景颜色以消除疑虑。