Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shorttermproject opened this issue Jan 23, 2012 · 0 comments
Open

Comments

@shorttermproject
Copy link

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;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant