1
在collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath方法即时尝试加载音频文件数组到收藏视图单元格,但基于indexPath行它跳过索引0单元格和索引1单元格它正在播放音频文件当细胞选择。我无法理解为什么。collectionView didSelectItemAtIndexPath
这里是我的代码
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
audioArray =[[NSArray alloc] initWithObjects:@"0", @"1", @"2", @"3", nil];
NSString *filePath = [audioArray objectAtIndex:indexPath.row];
NSString *audioFilePath = [[NSBundle mainBundle] pathForResource:filePath ofType: @"mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: audioFilePath];
audioPlayer = [[AVAudioPlayer alloc]
initWithContentsOfURL:fileURL error:nil];
}
如果有人能在正确的方向指向我。我会感激。
感谢您的帮助。