作者darktt (小朱)
看板MacDev
标题Re: [问题] 请教关於CollectionView上面的Button。
时间Thu Aug 7 21:40:44 2014
不知道这个问题是否节解决了,
不过我最近也正在用 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 可以使用来播放多个音乐或影片,
这样子可以解决播放的问题。
--
#1ID_Wqk2 (iPhone) [ptt.cc]
[问题] 记录天数的app
1F:推 xinya707:Days matter 倒数忌日都有 09/17 14:40
2F:→ xinya707:记日 09/17 14:41
3F:→ Decill:一楼我知道是输入法问题 不过我还是忍不住笑了 09/17 14:44
4F:→ happyfuture:1F好吓人阿XD 09/17 14:46
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 220.133.234.121
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/MacDev/M.1407418849.A.A66.html
5F:→ whitefur:建议不要用superview来取cell, 因为不能保证你拿到的东西 08/07 22:04
6F:→ whitefur:用contentView比较安全 08/07 22:06
7F:推 crazyni68:我已经解决了~谢谢你们的意见~: ) 08/08 00:35