Re: [問題] 請教關於CollectionView上面的Button。
不知道這個問題是否節解決了,
不過我最近也正在用 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
推
09/17 14:40,
09/17 14:40
→
09/17 14:41,
09/17 14:41
→
09/17 14:44,
09/17 14:44
→
09/17 14:46,
09/17 14:46
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.133.234.121
※ 文章網址: http://www.ptt.cc/bbs/MacDev/M.1407418849.A.A66.html
→
08/07 22:04, , 1F
08/07 22:04, 1F
→
08/07 22:06, , 2F
08/07 22:06, 2F
推
08/08 00:35, , 3F
08/08 00:35, 3F
討論串 (同標題文章)
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章