Sur*_*ran 1 objective-c uitableview ios
我有一个表格视图,显示数组中的联系人.我通过以下方式设置表视图委托.
-(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;
}
Run Code Online (Sandbox Code Playgroud)
但表视图中的第一个单元格始终为空.它仅从第二个单元格开始显示.我认为这可能是标题视图.所以我使用以下委托方法删除了标头.
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 0.0;
}
Run Code Online (Sandbox Code Playgroud)
但还是有问题.我附上了关于这个问题的截图.
任何帮助将不胜感激.
你TableView
很好,它工作正常,这是由于包含的其他一些问题iOS 7
,自动滚动插入.为了解决这个问题,去你的故事板,并选择其中你的视图-控制TableView
IS和选择ViewController
,选择Properties
的是ViewController
,取消选中此复选框,它读作Adjust ScrollView Insets
.看到这个屏幕截图,