我有一个表格 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;
}
但是还是有问题。我附上了有关此问题的屏幕截图。
任何帮助将不胜感激。
最佳答案
您的 TableView
很好并且工作正常,这是由于 iOS 7
中包含的一些其他问题,自动滚动插图。要解决此问题,请转到您的 Storyboard并选择您的 TableView
所在的 View Controller 。是并选择ViewController
并选择 Properties
其中ViewController
, 并取消选中此复选框,读作 Adjust ScrollView Insets
.看到这个屏幕截图,
关于ios - 表格中的第一个单元格始终为空。仅从第二个单元格显示 - objective-c ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21300609/