0

Xcode8 への更新後、次のコードが機能しなくなりました。

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {


    let cell = collectionView.superview!.superview as! UITableViewCell
    let table = cell.superview!.superview as! UITableView
    let indexPath = table.indexPath(for: cell)

現在、indexPath の値は常に nil です。何か案は?

4

1 に答える 1

0

最後の行を次のように置き換えることで問題を解決しました

let indexPath = table.indexPathForRow(at: cell.center)
于 2016-10-03T15:23:36.750 に答える