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 的值始终为零。有任何想法吗?

4

1 回答 1

0

我已经通过将最后一行替换为

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