Skip to content

Instantly share code, notes, and snippets.

@kchromik
Created November 10, 2013 13:05
Show Gist options
  • Save kchromik/7398018 to your computer and use it in GitHub Desktop.
Save kchromik/7398018 to your computer and use it in GitHub Desktop.
- (void)viewDidLoad
{
[self buildCameraRollLibrary];
}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section;
{
return itemList.count;
}
// creates all cells of the current collectionView
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
// we're going to use a custom UICollectionViewCell, which will hold an image and its label
SPCell *cell = [cv dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
// make the cell's title from title of current MPMediaItem
MPMediaItem *item = [itemList objectAtIndex:indexPath.row];
NSString* title = [item valueForProperty:MPMediaItemPropertyTitle];
cell.titleLabel.text = [NSString stringWithFormat:@"%@", title];
NSNumber *duration=[item valueForProperty:MPMediaItemPropertyPlaybackDuration];
double seconds = duration.doubleValue;
int secondsInt = round(seconds);
int minutes = secondsInt/60;
secondsInt -= minutes*60;
cell.durationLabel.text = [NSString stringWithFormat:@"%.2i:%.2i", minutes, secondsInt];
cell.thumbnail.image = [thumbnails objectAtIndex:indexPath.row];
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment