JGMediaPicker
JGMediaPicker copied to clipboard
Some tracks with no meta data for track number come up as 0
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; }