JGMediaPicker icon indicating copy to clipboard operation
JGMediaPicker copied to clipboard

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

Open shorttermproject opened this issue 13 years ago • 0 comments

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

shorttermproject avatar Jan 23 '12 04:01 shorttermproject