0
私は、MPMediaItemsとボタン(他のものの中でも)で設定されたカスタムセルを使ってUITableViewを持っています。 didSelectRowAtIndexPathではなく、特定のセルのMPMediaItemでどのボタンがタップされているかに関して、私はアクションを実行しようとしています。私はいろいろなアプローチを試してきましたが、タグは可能性が高いと信じていますが、正しい実装を得ることはできません。私は、コレクションの最初のアイテムまたは最後のアイテムを取得するようにみえるだけです。 MPMediaItemsを扱うときにタグを設定する正しい方法は何ですか?一部のコードは以下のとおりです。カスタムセル内のタグとMPMediaItems
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell : SongCell = self.songsTableView.dequeueReusableCellWithIdentifier("cell") as! SongCell
cell.button.addTarget(self, action: #selector(handleSelection), forControlEvents: .TouchUpInside)
cell.tag = indexPath.row //removing this line results in getting the first item in the collection, using it results in the last (understandably so)
index = cell.tag
return cell
}
@IBAction func handleSelection(sender: AnyObject)
{
let songToHandle = tableData.items![index!]
queryAsCollectionItems?.append()
}
ここで問題は解決しましたか? –
これはうまくいきました...ありがとう! – rocketman240