谁能帮我理解我做错了什么UITableView
?
我已经设置了一个包含两个自定义单元格的消息列表 - 取决于变量是真还是假。我想将我的数据应用到相关的单元格 - 但我得到的是两个自定义单元格在另一个之上重复 3 次,如下所示(前景中的单元格没有设置样式 - 只是举例!)
这是我的代码 -
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
static NSString *CellIdentifierRead = @"CellRead";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
customCellRead *cellRead = [tableView dequeueReusableCellWithIdentifier:CellIdentifierRead forIndexPath:indexPath];
notifications *n = [self.GPTNotifications objectAtIndex:indexPath.row];
if (n.read == false) {
cellRead.readText.text =n.notifMessage;
cellRead.reDate.text =n.notifDateD;
cellRead.resub.text = n.notifDateD;
}
if (n.read == true) {
cell.notifTitle.text = n.notifTitleD;
cell.notifDate.text = n.notifDateD;
cell.notifMsg.text = n.notifMessage;
}
// Configure the cell...
return cell;
return cellRead;
}