Re: [问题] 请教关于CollectionView上面的Button。

楼主: darktt (小朱)   2014-08-07 21:40:44
不知道这个问题是否节解决了,
不过我最近也正在用 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 可以使用来播放多个音乐或影片,
这样子可以解决播放的问题。
作者: whitefur (白毛)   2014-08-07 22:04:00
建议不要用superview来取cell, 因为不能保证你拿到的东西用contentView比较安全
作者: crazyni68 (めがね)   2014-08-08 00:35:00
我已经解决了~谢谢你们的意见~: )
作者: xinya707 (妈我在这)   2014-09-17 14:40:00
Days matter 倒数忌日都有记日
作者: Decill (inner peace)   2014-09-17 14:44:00
一楼我知道是输入法问题 不过我还是忍不住笑了
作者: happyfuture (!)   2014-09-17 14:46:00
1F好吓人阿XD

Links booklink

Contact Us: admin [ a t ] ucptt.com