我想添加一个静态单元格作为我的动态tableview中的第一个单元格。我在这里看到了其他问题,但他们似乎没有工作。任何帮助是极大的赞赏。我实际上得到了我的单元格,但它取代了我的第一个动态单元格,当我在表格视图中滚动时,我的应用程序崩溃。在动态tableview中添加静态单元格
这是我在迄今为止已到达:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustomSideBarCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (indexPath.row < NUMBER_OF_STATIC_CELLS) {
cell.sidePic.image = _secondImage;
cell.sideOption.text = @"Everything";
return cell;
}
else {
cell.sidePic.image = _secondImage;
_tempResults = [_tableData objectAtIndex:indexPath.row];
_optionCategory = [[_tempResults objectForKey:@"post"] objectForKey:@"category_name"];
cell.sideOption.text = _optionCategory;
您确切的问题是什么?你有错误信息吗? – Hannes
就像我提到的,第一个问题是我的静态单元“覆盖”或替换第一个动态单元,而不是在它之上。第二个问题是当我尝试在tableview中滚动时,应用程序崩溃。 – mreynol
这是抛出的错误:由于未捕获的异常'NSRangeException',理由:' - [__ NSCFArray objectAtIndex:]:index(14)超出界限(14)'' – mreynol