不知道这个问题是否节解决了,
不过我最近也正在用 CollectionView,
所以可以做点帮忙。
※ 引述《kiii210 (HelloWorld!)》之铭言:
: 建立一个mp3名称的array,顺序跟你的textView要用的array一样
: -> @[@"song1",@"song2"];
: 在cellForItemAtIndexPath里面给每一个button一个编号
: -> button.tag = indexPath.row
其实不用这样子做,
只要 button.superview 就是 cell 了,
不过这要看 button 是否是直接加进 cell 或是 cell.contentView,
不管哪一个只要一直用 superview 就可以取得上一层的 view。
就像是这样子
UIView *cellContentView = button.superview;
UICollectionViewCell *cell = (UICollectionViewCell *)cellContentView.superview;
UICollectionView *collectionView = (UICollectionView *)cell.superview;
只要这样子就能知道 cell 所属的 indexPath 了,
这样子也不会出现因为 button 的 tag 被 reuse 而设定错误的问题了。
另外,AVPlayer 有另外一个 AVQueuePlayer 可以使用来播放多个音乐或影片,
这样子可以解决播放的问题。