ios - 表格中的第一个单元格始终为空。仅从第二个单元格显示 - objective-c

标签 ios objective-c uitableview

我有一个表格 View ,它显示数组中的联系人。我通过以下方式设置 TableView 代表。

-(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;

}

但表格 View 中的第一个单元格始终为空。它仅从第二个单元格开始显示。我认为这可能是标题 View 。所以我使用以下委托(delegate)方法删除了标题。
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.0;

}

但是还是有问题。我附上了有关此问题的屏幕截图。 screenshot

任何帮助将不胜感激。

最佳答案

您的 TableView很好并且工作正常,这是由于 iOS 7 中包含的一些其他问题,自动滚动插图。要解决此问题,请转到您的 Storyboard并选择您的 TableView 所在的 View Controller 。是并选择ViewController并选择 Properties其中ViewController , 并取消选中此复选框,读作 Adjust ScrollView Insets .看到这个屏幕截图,

enter image description here

关于ios - 表格中的第一个单元格始终为空。仅从第二个单元格显示 - objective-c ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21300609/

相关文章:

swift - 表格单元格中的事件指示器 View

ios - 如果 navigationBar.translucent 为 NO,则 UITableView 底部区域保持在屏幕之外;

ios - 是否可以通过 pubnub 在多个应用程序上发送 IOS 推送通知?

ios - 如何检查 NSDictionary 的哪些键可用?

iphone - 弹出表格 View

ios - 按需滚动不断调用

iOS:重新加载 TableView 不起作用

ios - 带有一个可见单元格 : determine which is most visible 的 UITableView

ios - 将图像添加到 navigationItem 的标题

objective-c - 如何分发静态库?