我正在尝试使用自定义分隔符创建一个表格视图。我制作了一个包含内容的自定义单元格,另一个只包含一个带有分隔符的 UIImageView。问题在于如何访问内容。我不能使用 indexPath.row
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier: @"CustomCell"];
if(cell == nil)
{
cell = [[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil] objectAtIndex:0];
}
SeparatorCell *cellSeparator = (SeparatorCell *) [tableView dequeueReusableCellWithIdentifier: @"SeparatorCell"];
if(cellSeparator == nil)
{
cellSeparator = [[[NSBundle mainBundle] loadNibNamed:@"SeparatorCell" owner:self options:nil] objectAtIndex:0];
}
if(indexPath.row % 2)
{
UIFont * myCustomFont = [UIFont fontWithName:@"Arial Black" size:16];
[cell.titulo setFont:myCustomFont];
cell.titulo.textColor = [UIColor colorWithRed:103/255.0f green:169/255.0f blue:0/255.0f alpha:1];
cell.titulo.text = [Title objectAtIndex:myRow];
cell.subtitle.text = [Subtitle objectAtIndex:myRow];
cell.tag = myRow;
myRow++;
}
else [cellSeparator.imagem setImage:[UIImage imageNamed:@"CustomSeparator.png"]];
if(indexPath.row % 2) return cell;
else return cellSeparator;
}
我的行
是一个全局 NSInteger。
我已经试过了
if(myRow == Title.count) myRow=0;
else myRow++;