스크롤 할 때 응용 프로그램이 충돌합니다. 나는 UICollectionView
을 만들었고 스크롤을 많이하면 첫 번째 행을 더 이상 볼 수 없어 앱이 다운됩니다. 나는 이것을 어떻게 해결할 지 정말로 모른다. 이것은 내 응용 프로그램의 일부로 어디서 CollectionView
을 만듭니다. 셀의 콘텐츠는 iTunes와 동기화 된 내 동영상의 모든 동영상의 미리보기 이미지를 보유하고있는 이미지입니다. 모든 것이 작동하지만 1 행 이상 스크롤하지는 않습니다.UICollectionView
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section;
{
return itemList.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
// we're going to use a custom UICollectionViewCell, which will hold an image and its label
//NSLog(@"%@",indexPath);
VPCell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
// make the cell's title from title of current MPMediaItem
MPMediaItem *item = [itemList objectAtIndex:cellMediaItemCounter];
NSString* title = [item valueForProperty:MPMediaItemPropertyTitle];
cell.label.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];
// load the thumbnail for this cell
NSURL *url = [item valueForProperty:MPMediaItemPropertyAssetURL];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
UIImage *thumbnail = [player thumbnailImageAtTime:13.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
//set thumbnail to cell image
cell.image.image = thumbnail;
cellMediaItemCounter++;
//pause initiated player (to get thumbnail), if not it's playing in background
player=nil;
return cell;
}
고맙습니다.
의 오류는 무엇을 말하는가? – Zen
어떤 버전의 ios입니까? –
@Vame의 솔루션이 완벽하게 작동합니다! – kchromik