Created
November 10, 2013 13:05
-
-
Save kchromik/7398018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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