Skip to content

Some tracks with no meta data for track number come up as 0 #5

Description

@shorttermproject

If the track number is 0, I use the row index. I thing Apple does it too.

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    static NSString *CellIdentifier = @"AlbumTrackCell";
    JGAlbumTrackTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"JGAlbumTrackTableViewCell" owner:self options:nil];
    cell = self.albumTrackTableViewCell;
    self.albumTrackTableViewCell = nil;
    }

    MPMediaItem *mediaItem = [[[self albumCollection] items] objectAtIndex:indexPath.row];
    NSNumber * trackNumber = [mediaItem trackNumber];
    if(!trackNumber || ![trackNumber intValue])
    trackNumber = [NSNumber numberWithInt:indexPath.row+1];
    cell.trackNumberLabel.text = [NSString stringWithFormat:@"%d",[trackNumber intValue]];
    cell.trackNameLabel.text = [mediaItem title];
    cell.trackLengthLabel.text = [mediaItem trackLengthString];

    //make odd rows gray
    cell.backgroundView.backgroundColor = indexPath.row % 2 != 0 ? kGrayBackgroundColor : [UIColor whiteColor];

    return cell;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions