We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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;
}
The text was updated successfully, but these errors were encountered: